3
votes
1answer
54 views
Force an object to evaluate to false
I'm guessing this is probably application specific however I am using node.js - as long as it works in the v8 engine, I don't mind.
I'm trying to create an Object that evaluates to false, for ...
0
votes
0answers
21 views
Node.js handling response from http request
I have some code as follows:
exports.post = function(request, response) {
var httpRequest = require('request');
var uri = "url..";
httpRequest(uri, function(err, responseHeaders, ...
4
votes
4answers
488 views
node - restart server after editing specific files
I'd like to automatically restart the server after particular files are edited.
Is there anything I can install to help me do that? - or will I need to watch the folder run a script accordingly.
Any ...
1
vote
1answer
16 views
Cancelling default behaviour in sails.js model Lifecycle callback
Let's say we create a sails.js model, which sometimes should be saved into DB when posted (as usual), and sometimes – should not. Can we perform this logic in a model lifecycle callback?
Basically, ...
0
votes
0answers
26 views
What is a good way to represent command-line arguments with JSON?
I'm trying to make improvements to the grunt-closure-linter npm project (so I can actually use it in a productive fashion), and here's where I'm stuck on it now:
I want to specify a way to pass ...
0
votes
1answer
42 views
javascript method doesn't have access to “this” in callback
Pretty new to Javascript and Node. I'm using express in Node to create a simple web app. In trying to separate concerns, I'm running into trouble.
The code looks like this:
var get_stuff = ...
0
votes
0answers
19 views
How to encrypt using PHP mcrypt and decrypt with node crypto
I have some PHP code that produces some ciphertext as follows:
<?php
$data = '12345678123456781234567812345678123456781234567812345678123456781234567812345678';
$ciphertext = ...
0
votes
0answers
19 views
Node.js client.emit only working after first try?
I am writing an app where I have a user login via an email and password. I have my node.js server return either a 'yes' or 'no' if the login is correct.
On the server, I can console.log the result ...
0
votes
0answers
36 views
Loop through posts' date in order to make archive in DocPad
Here's some pseudo-code of what I want to achieve:
for year in post.date
h1 year
for month in post.date
h2 month
ul
li post entry
That's the pseudo-code. However ...
3
votes
3answers
64 views
How does a javascript array store keys such as “02”
I was reading though Javascript, the definitive guide and came across a paragraph which said and I quote
If you index an array with a string that happens to be a non-negative
integer,it behaves ...
0
votes
2answers
49 views
How to end() a file stream
I am having a weird issue with a piece of sample code that I got here, the central part being this:
server.on('request', function(request, response) {
var file = fs.createWriteStream('copy.csv');
...
67
votes
5answers
46k views
How to use underscore.js as a template engine?
I'm trying to learn about new usages of javascript as a serverside language and as a functional language. Few days ago I heard about node.js and express framework. Then I saw about underscore.js as a ...
3
votes
0answers
91 views
Reference error is not thrown from MongoDB callback
Introduction
All people know that if we call undefined.test we will receive the following error (same for both: NodeJS and Javascript):
$ node
> undefined.test
TypeError: Cannot read property ...
0
votes
2answers
24 views
how to disable the UI until a response from the server with AngularJS
I am building a web app with angularjs and nodejs (express).
Many times in my app a user will do things that will comunicate with the server and according to the result things will happen.
Whenever ...
1
vote
1answer
54 views
compile order of node.js modules
The problem is that I have a number of separate modules which I export using module.exports and are inter dependent. Say-
mongohelper
transaction
server
conhandlr
appmin
Now, the server ...