Latest Node.js Recipes

Send a Facebook app notification from Node?

The Facebook JavaScript API lets you send app notifications from your client-side app:

FB.ui({ method: 'apprequests', message: 'Test Request' })

...which results in an app notification:

How can I reproduce this behavior on the server side...

Read the entire recipe Recipe added 54 minutes ago

Inspect a Method Chain with a Degugger in Node.js

I am trying to debug this kind of thing :

  .type('q', 'Hello World')
  .waitForTextPresent('Hello World')
    assert.ok(~title.indexOf('hello world'), 'Title...

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

Why don't mongodb session MongoStore's go away after session ends?

Even with

    secret: conf.secret,
    maxAge : new Date( + 360000),
    expires: new Date( + 360000),//I've tried both separately
    store : new MongoStore(conf.db),


The sessions in mongodb...

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

Minimizing data sent between client/server in javascript

I am trying to code a multiplayer game demo in javascipt using no libraries. Everything is going pretty good, but in order to get better performance to move forward I am going to have to try minimize the data I sent over my websockets or I won't be...

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

RabbitMQ message latency between producer and consumer

I'm running the node.js amqp-node client on a RabbitMQ server. I've set up a simple publish/consume test in two different ways - each produces a different latency and I can't work out why. The latency is measured from the time the message was sent to...

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

Amazon S3 EPIPE Error

UPDATE: got it working from the commandline after add a full access policy permissions to that user. Now when I do it with Node there is no error but I can't see the files in my s3 file manager.

I keep getting an EPIPE error using Amazon's S3...

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

Get signed_request in Node.js (Express) Facebook canvas app

is there any way how to get and parse signed_request in Node.js Facebook page tab app? I need to know page id and if user liked the page...

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

searching database with mongoose api and nodejs?

im using nodejs and mongoose to build an api, im trying to do the search feature, but it deosnt seem to query anything, the code.

app.get('/search', function(req,res){
    return Questions.find({text: "noodles"}, function(err,q){

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

how do I declare a variable that any client can access using

This is for a gaming application I use MySQL for most of my dirty work but I was hoping for a lightweight solution here.

I've noticed I can declare socket.clientid and every time that client emits to my server I can use socket.clientid

Is there a...

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

zeromq.node installation error Ubuntu 12.04: ' node-gyp rebuild'

I'm trying to install zeromq.node using:

$ npm install zmq

However, I keep getting the error below. Any help would be much appreciated.

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at...

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

Node.js mongoose performance

Is there somebody that has experience using mongoose.js as Node.js mapper for Mongodb at high scale?

I am wondering if I should use the native driver, so I keep everything lightweight or to write a simple wrapper.

If anybody got some tips, advise...

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

Everyauth vs Passport.js?

Everyauth and Passport.js seem to have very similar feature sets. What are some of the positive and negative comparisons between the two that would make me want to use one over the other?

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

MongoDB/Mongoose querying at a specific date?

Is it possible to query for a specific date ?

I found in the mongo Cookbook that we can do it for a range Querying for a Date Range Like that :

db.posts.find({"created_on": {"$gte": start, "$lt": end}})

But is it possible for a specific date...

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

node.js saving large floating point numbers into mongo for searching

I've been wrestling with my limited knowledge of real programming and need some help...

From within node.js and saving into MongoDB (using the native driver) I need to index and search some long numbers.

An example:

87 / 53

On 64-bit windows...

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

log every method?

Instead of having to create a custom logger for TRACE, e.g. following what methods were called and what classes were instantiated, is there an easy way to make all methods under a class log themselves? This is for a node.js application.


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

How to call end() on the http.ServerResponse Object?

I found the accepted answer in this question to answer an error handling question I had.

Note the comment though - a http.ServerResponse needs to be finished so that the application doesn't run out of memory eventually - this is a concern.

How would...

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

How do I set a MIME type before sending a file in Node.js?

When sending scripts from my Node.js server to the browser, in Google Chrome, I get this warning:

Resource interpreted as Script but transferred with MIME type text/plain

I Google'd around, and found out that it's a server-side problem,...

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

how to generate unique id like facebook, google+ in NodeJS

I'm using nodeJS and cassandra

I'm currently using UUID v1 as unique id

but, I think uuid is too long

I want to generate numeric unique id like fb and G+, which is shorter

and don't have to check if the id exist in DB or not before...

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

Error installing Nodejs on CentOS 5 server - no module bz2

I'm trying to get NodeJS installed on my CentOS 5 server

I got Python 2.6 installed, and I got ./configure to work, but when I run the make command I get this result

[root@catch24dev node-v0.8.6]# make
make -C out BUILDTYPE=Release...

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

how to efficiently transfer file between 2 node.js instances?

I'm developing chat application using app.js which is webkit+node.js framework. So i have node.js plus bridged web browser environment on both sides. I want to make file transfer feature somewhat similar to Skype one.

So, initial idea is...

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

Why is there separate mongo.Server and mongo.Db in mongodb-native driver?

I am just learning mongodb-native driver for nodejs.

I connect like this.

var mongo=require("mongodb")

var serv=mongo.Server("localhost", 27017)
var dbase=mongo.Db("MyDatabase", serv)

And that works. But if I try to create a new database...

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

how to generate api documentation

I need to write some api documentation for a REST API that I've created. Are there tools that will stub out a nice html output similar in style to the underscore api documentation? Or perhaps something that will output something as a twitter...

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

Accessing Azure ServiceConfiguration settings in Node.js

I'm coming to the beta deployment phase of building a Node.js application running through iisnode on Windows Azure. Having set up multiple instances, as well as production/staging separation, my research has led me to the following conclusion:


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

Create WebSockets between a TCP server and HTTP server in node.js

I have created a TCP server using Node.js which listens to clients connections. I need to transmit data from TCP server to HTTP server again in Node.js possibly through a Websocket (

However, I do not know how to create such connection...

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

Being both event-driven servers, why node.js needs async code where Nginx doesn't?

The question is in the title. In another words, if Nginx works as the same event-driven async IO model of node.js, why doesn't it requires writing async style code? I know, Nginx is NOT actually executing any code, rather proxying them to who can....

Read the entire recipe Recipe added 1 day ago