Latest Node.js Recipes

Link facebook data to currently logged in user with Passport.js

I'm using passport.js and I'm wounding if I can link a facebook id to a logged in user's account. Something like this:

passport.use( new FacebookStrategy({
        consumerKey: ---
        consumerSecret: ---
        callbackURL: "http://mycallback"
...

Read the entire recipe Recipe added 31 minutes ago

The URI string is too Long exception - Making a request to node.js

I just ran into this issue while making a GET request to a node.js server from .NET. Ultimately, I am trying to pass a large JSON object through the query string. I have been looking to see if there is a way to increase the size of the URI in .NET...

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

Advantages of bundledDependencies over normal dependencies in NPM

npm allows us to specify bundledDependencies but what are the advantages of doing so? I guess if we want to make absolutely sure we get the right version even if the module we reference gets deleted, or perhaps there is a speed benefit with...

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

Profiling Node.js using DTrace

I am currently profiling my node.js application.I found this blog: http://blog.nodejs.org/2012/04/25/profiling-node-js/ that suggests I should use Dtrace. I installed dtrace on ubuntu 12.04 using steps given here: ...

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

Hook.io on Heroku

I am creating a Node.js app on Heroku and have run into an issue. I am trying to use Hook.io in my application but am getting a "Bad Bind" error from Heroku because Hook uses port 5000. Does anyone know of a way around this, maybe by somehow telling...

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

Mongoose: how to model object hierarchy?

I am using Mongoose 2.7.0 with node.js.

How can I describe a schema with a single embedded object?

Effectively I want to end up my schema matching with a JSON structure like:

{
    title: "",
    position: {
       loc: [0, 0],
       street: "",
 ...

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

Why is MongoDB unable to insert the same JSON twice in a row?

I'm using the Node.js native driver. The following works fine

db.collection("test").insert({hello:'world_safe'}, {safe: true}, function(err, result) {
    if (err) throw err;
    db.collection("test").insert({hello:'world_safe'}, {safe: true},...

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

REST API: How to search for other attribute

I use node.js as REST API. There are following actions available:

  1. /contacts, GET, finds all contacts
  2. /contacts, POST, creats new contact
  3. /contacts/:id, GET, shows or gets specifiy contact by it's id
  4. /contacts/:id, PUT, updates a specific...

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

Node.js global variable property is purged

my problem is not about "memory leakage", but about "memory purge" of node.js (expressjs) app.

My app should maintain some objects in memory for the fast look-up's during the service. For the time being (one or two days) after starting the app,...

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

How to integrate Expressjs and UnderscoreJS

I'm making an Expressjs app however I don't particularly want to use Jade. I installed UnderscoreJS successfully into my app so I can use its templating capabilities (as well as some of its other features).

My question is when I want to insert, for...

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

deploying a node.js on a new domain

I have a server that runs different websites on different ports. All of them (but one) are Apache servers and thanks to webmin, I managed to have, for instance, example.com point to 123.123.123.123:80 and example.fr to 123.123.123.123:8000, somehow...

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

Persistent variables in nodeJS

I am writing a node app that needs to remember data across connection iterations of the createServer() callback. Is there a simple way that doesn't involve databases or file r/w? I've sofar attempted creating objects in the respective modules and even...

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

Determining session ID from WebDriverJS

I'm trying to run WebDriverJS on the browser, but the documentation is somewhat vague on how to get it controlling the host browser. Here, it says:

Launching a browser to run a WebDriver test against another browser is a tad redundant ...

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

Get Hubot to talk at a certain time?

I'm thinking about making a Hubot clock-based notifier (think "It's 5, time to go home!" but less annoying and for a different reason). What's the best way to go about doing something like this in a Hubot script?

[edit] Here's an example using...

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

Which azure service, i should choose for my node.js app?

I am new to Microsoft windows azure cloud and want to run my node.js app in azure cloud. I read the windows azure Node.js Developer Center site ( https://www.windowsazure.com/en-us/develop/nodejs/ ) and it seems my app can run in azure cloud multiple...

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

What are all the ways CouchDB reponses fail?

I'm building a Node.js application on the express.js framework with CouchDB as a database. I'm utilizing CouchDB's session api for maintaining session state, and various databases for different sections of data.

On essentially every request my...

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

Zombie.js Returns Improper Page Content

I am new to zombie and just trying to get a basic test running. I have the following code:

var Browser = require('zombie');

var startTime = +new Date();

Browser.visit("http://zombie.labnotes.org/", function(e, browser) {
    var duration;

   ...

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

Convert a directory structure in the filesystem to JSON with Node.js

I have a file structure like this:

root
|_ fruits
|___ apple
|______images
|________ apple001.jpg
|________ apple002.jpg
|_ animals
|___ cat
|______images
|________ cat001.jpg
|________ cat002.jpg

I would like to, using Javascript and Node.js,...

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

ParseError on Node.js http request

Hello StackOverflow community!

I started to learn Node.js recently, and decided to implement a reverse HTTP proxy as a task. There were a couple of rough places, which I managed to get through on my own, but now I'm a bit of stuck, and need your...

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

pushing tty output to node

For the satisfaction of my curiosity gene i'd like to play with bash/node combo. I don't know how to make those 2 talk together. I just had a great smile on my face finding about TTY.JS ;-)

How do I feed terminal's output (sdtout?) to node? I...

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

How to determine is string represent a directory or a file in Node.js?

Possible Duplicate:
Check synchronously if file/directory exists in Node.js

For example, i have a string "C:/dev/image.folder", and i want to determine, is it directory or a file (synchronously). How can i do it?

Thanks in advance!

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

Rendering HTML in variable using Jade

I have some text stored in a variable which contains some HTML. For example, the cat in the hat. However, when I render it in Jade, it shows up with the tags instead of rendering the formatting. How can I fix this?

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

Where is ToCString's header, or how to convert arguments to cstrings?

I'm trying to use ToCString in a NodeJS addon.

String::Utf8Value foo_utf8(args[0]->ToString());
const char *foo = ToCString(foo_utf8);

I can't find it's header, and if I manually prototype it as:

const char* ToCString(const v8::String::Utf8Value&...

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

Redis Bitset operations in Node.js / Express.js

I'm very new to Node.js and Redis. I read this article, and want to use a bitset to store all the user information for my Express.js app, as mentioned in this article: ...

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

Encryption and Decryption between Android, PHP & node.js

I'm trying to encrypt a string in Java on Android, and then decrypt it using PHP and/or node.js

I've tried http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php, but only the first half the returned hex string works.

I want the...

Read the entire recipe Recipe added 1 day ago