Latest Node.js Recipes

param-set type for LoadBalancerPorts

I'm trying to use to delete load balancer listeners ( but I could not figure out what param-set type looks like. I have tried [1000, 2000] but it did not work. Here is partial...

Read the entire recipe Recipe added 14 minutes ago

Weird inheritance in Node.js

I've been poking into some Node.js modules in the hopes of learning something I could have missed while creating a module with similar functionality. Then I came across this code from Hound:

function Hound() {
    //why this?

Read the entire recipe Recipe added 1 hour, 10 minutes ago

how to use dustjs-linkedin as client side templating?

I get the idea of server and client side templating, but dust.js confuses me a little bit.

In order to use dust.js for client side templating, you need three steps:

  1. complie the template
  2. load the template
  3. render the template


But where do...

Read the entire recipe Recipe added 2 hours, 9 minutes ago

Retrieve roster in node-xmpp

I'm having trouble understanding how to retrieve an XMPP roster (and eventually the presence state of each contact) in node-xmpp (GTalk account).

My example code can login and connect, but I'm a bit lost as to what to send and listen for:

var xmpp =...

Read the entire recipe Recipe added 3 hours, 12 minutes ago

Encoding problems when writing to the console in node.js

I'm having problems with the encoding in node.js. I'm running it on windows and for example if I run this simple program:

console.log("trying áéíóú");

I get in the console:

trying ?????

Is this normal? How can I solve this problem?


Read the entire recipe Recipe added 4 hours, 13 minutes ago

Adding variables to connect-assets

I am trying to add some variables from my app.js file into the file compiled by connect-assets.

I have a file called file.ejs

<%- js('code.js') %>
<input type="text" value="Doe">

In app.js I have:

 app.locals.url = ''


Read the entire recipe Recipe added 5 hours, 13 minutes ago

Mongoose.js - array of geospatial locations

I would need to have something like this

    event : "something",
    location : [
            long:25, lat:34
            long:25, lat:35

Is this possible? And is it...

Read the entire recipe Recipe added 6 hours, 9 minutes ago

Express.js cannot access static files even after configuring express.static

I tried localhost:3000/index.html (where I put a static page), localhost:3000/javascripts/dio.js (where I put js) localhost:3000/images/dio1.jpg (where I put the images), All cannot be accessed. Why? What is wrong?

My app.js define:

var express =...

Read the entire recipe Recipe added 7 hours, 12 minutes ago

Comparmentalize HTML via Javascript or jQuery

I'm trying to come up with a purely front-end solution to a common practice.

In the past, I've stored the HTML for reused website elements (like the <nav>, <header>, <footer>, etc.) in a functions.php file, and used php functions to call these things...

Read the entire recipe Recipe added 8 hours, 9 minutes ago

Debug variable with EJS

I would like to set a global variable in EJS to show/hide some elements. I would like to be able to set this variable once and have it propogate through all the views. What is the best way to do this?

The other parts of my stack are...

Read the entire recipe Recipe added 9 hours, 12 minutes ago

What is the best practice for mongoDB to handle 1-n n-n relationships?

In relational database, 1-n n-n relationships mean 2 or more tables. But in mongoDB, since it is possible to directly store those things into one model like this:

  content: String, 
  uid: String,

I am getting...

Read the entire recipe Recipe added 10 hours, 9 minutes ago

How to create custom client events in node.js +

I'm just starting out with node.js, and from what I can tell so far, the way clients communicate with the server is through:

//Client Code 1
var iosocket = io.connect();
iosocket.on('connect', function () {
   iosocket.send("Here's some...

Read the entire recipe Recipe added 11 hours, 11 minutes ago

Which Amazon EC2 plan to choose for 60 concurrent node.js servers?

I have a local web service which is using 60 running node.js servers. Now I want web service to drag over on Amazon EC2.
Which the best plan to choose to run 60 concurrent node.js servers?

As I understand it, for optimal performance need to run one...

Read the entire recipe Recipe added 12 hours, 11 minutes ago

Websockets in phonegap with an app that uses

We are working on a phonegap app and are using node.js in combination with We know that websockets aren't supported by phonegap yet, but that there are some ways to make them work ( and...

Read the entire recipe Recipe added 13 hours, 17 minutes ago

Setting PATH on Makefile - Node.js

I want to use api-easy to test my REST app. I have it in the dependences inside the package.json, so when I run npm install it's installed in ./node_modules

I'm trying to add the api-easy to the path like this question.

Since I'm using a Makefile I...

Read the entire recipe Recipe added 14 hours, 12 minutes ago

Storing sessions with passportjs, Express and monogodb

I'm having trouble getting sessions with mongodb to work properly. I've setup the following code which, without a problem, creates the user.

I can also see my sessions database being populated which looks like this:


Read the entire recipe Recipe added 15 hours, 11 minutes ago

How do I add a server side route that can call Meteor code?

I am trying to allow users to upload images to a site I have built with Meteor, which requires a server-side route I can POST data to. Is there a way to set up a route server side such that I can call Meteor code from it (for example, a route that I...

Read the entire recipe Recipe added 16 hours, 13 minutes ago

Appfog, nodejs, Environment variable: service doesn't contain at one point but does at another

I have the following code in my server.js:

throw new Error('The databasenumber was wrong, or you didn\'t bind one.' + process.env.VCAP_SERVICES + " === " + process.env.VCAP_SERVICES["mysql-5.1"]);

The output at this moment is:


Read the entire recipe Recipe added 17 hours, 16 minutes ago

nodejs, how to check if session is defined on every page

I am using express to develop a simple website. I just get confused about how to make the nodejs check session before rendering any page, so that if a user did not login, he cannot see anything.

I think in rails it is quite simple, just add some...

Read the entire recipe Recipe added 18 hours, 9 minutes ago

development/build tool for client side web application

I am working on a pretty large node web application and realize that my workflow is suboptimal. The server side code is quite well organized into node modules. However most of the heavy lifting in the application happens on the client side code.


Read the entire recipe Recipe added 19 hours, 14 minutes ago

.apply without changing scope

I want to use the JavaScript .apply method to functions of a thrift compiled for Node.js. The thrift .js file has code like this:

var NimbusClient = exports.Client = function(output, pClass) {
    this.output = output;
    this.pClass = pClass;

Read the entire recipe Recipe added 20 hours, 11 minutes ago

How do I have foreman reload node.js when a file is changed?

I currently use supervisor to run my node.js app when developing locally. This has been great, but I currently store all my configs in my .bash_profile, I want to move them to a .env file.

Is there a way to get the environment loading features of...

Read the entire recipe Recipe added 21 hours, 10 minutes ago

How to handle deep and complex data structure with restify.js

I've seen examples of Restify where all the endpoints are located on the root: /users, /data, etc. I know it's possible to implement nesting like so:

server.get('/users/:user/data/:id', returnData);

and the req.params variable will have all of the...

Read the entire recipe Recipe added 22 hours, 13 minutes ago

MongoDB nodejs driver not returning more than 100000 rows

This is an example to replicate my issue:

I populate my collection with 1million documents like this:

for(i=1; i<=1000000; i++){
     db.numbers.insert({_id:i, stuff:"Some data", signUpDate: new Date()});

Read the entire recipe Recipe added 23 hours, 13 minutes ago

Create a RESTful web service with oauth using Node.js

I want to create a RESTful webs ervice with OAuth by Node.js, but I don't know where to start with.

I mean I want to make my own server (something like Google or Facebook does). For example: you make an App, when your App wants to get some Facebook...

Read the entire recipe Recipe added 1 day ago