Latest Node.js Recipes

Coffeescript Cakefile - Array of cmdline options

Is it possible to pass multiple cmdline args to a Cakefile and capture those values in an array? For example something like this:

option '', '--compilation-level [LEVEL]', 'Description...'
task "build", "compile js", (options)->
    compilationLevels...

Read the entire recipe Recipe added 26 minutes ago

Deploying a production Node.js server

I've written a Node.js app, I'm looking to get it running on one of our production machines. This seems like a pretty common request yet I can't find an adequate solution. Is there not established solutions for deploying production Node.js apps?

The...

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

NODE_PATH error with node.js while attempting to setup jsctags for vim

I am trying to setup doctorjs on my windows machine, to work with vim's tagbar, but I think this may be a node.js question more than anything else. I'm following this tutorial. Even after I set my NODE_PATH, I still get an error claiming that it...

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

How to post large amount of json data (not file) in nodejs/express

So I am doing an ajax(jquery) post that uploads quite a big amount of json data. When posting a large data, the data is generally broken into chunks. So we have to listen for post data requests and construct a full buffer of the upload data. Something...

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

Node.js Accessing parent modules

I am working on a CMS system for Node.js, I have a quick question for those Node.js Pro's

I am creating modules and requiring modules within those modules, but if I have already included this module in the parent module, can I access those required...

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

Changing app from one language to another in heroku

Is it possible to switch a Heroku app on the Cedar stack from one language to another?

In this particular instance I am trying to migrate an app from PHP to NodeJS, which is being detected as a NodeJS app after performing a git push:

-----> Heroku...

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

Permission issues installing npm on OSX

I'm having issues installing the node package manager "npm".

On the website it prompts you to do a 1 line install as follows...

curl http://npmjs.org/install.sh | sh

This spits out the following install error...

$ curl...

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

Node.js Parsing HTML

OK, I am creating a node.js module that will be a simple and fast HTML parser. Basically I want to be able to parse an HTML file for a certain tag, for example:

<html>
<head>

     <title><%=title%></title>

</head>
<body>

    ...

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

2-legged server side oauth implementation in node.js

I have a node.js API that I want to protect via 2-legged OAuth. Was wondering if anyone knows of a server side implementation for this. Please note that this is for server to server communication and is not to provide user authentication via a 3rd...

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

What does Connect.js methodOverride do?

The Connect.js very terse documentation says methodOverride

Provides faux HTTP method support.

What does that mean? The obvious Google search is less than helpful. Why is methodOverride useful?

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

Why can't I extend everyone's pocket in nowjs?

I'm trying to provide functions in everyone's pocket of nowjs. I'd like to do so by _.extending everyone's pocket, i.e. everyone.now. For some reason which I cannot understand, _.extend fails to properly provide the function at the client side.

This...

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

Implementing timeouts for node.js callbacks

This is a typical situation in node.js:

asyncFunction(arguments, callback);

When asynFunction completes, callback gets called. A problem I see with this pattern is that, if asyncFunction never completes (and asynFunction doesn't have a built-in...

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

Testing Closure Compiler output under Node.js

I'd like to use Vows to test DOM-free JavaScript code, ideally directly running against the compiled JS. My Vows are written in CoffeeScript, but I'm not sure how to load my JS; I've tried just inlining it using eval:

vows = require "vows"
assert =...

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

Internal scripts and style-sheets always points to index file (Node.JS)

This is really weird problem. I just installed Node.JS on my system (Fedora).

I have three files in /var/www/mirror/:

  • server.js
  • client.js
  • index.html

File server.js is the one I call via CLI: node server.js.

It, basically, returns...

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

Deduplicating using nodeJS

My goal is to take in a CSV file which contains approximately 4 million records and process each record while scrubbing the data of a particular field. The scrubbing process we have actually creates a reversible hash but is a time consuming process...

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

Get new contents of a file

A node.js script calls the maxima computer algebra system and redirects my input to the stdin of maxima. Maxima the writes the processed input to a temporary text file where there is a new line for every result maxima returns.

Can node watch for new...

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

Accessing the session object after a POST

I'm using express.js with the session middleware. This is my code:

var express = require('express'),
    app = express.createServer();

app.configure(function () {
   app.use(express.cookieParser())
      .use(express.session({ secret: 'blabla'...

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

When to close MongoDB database connection in Nodejs

Working with Nodejs and MongoDB through Node MongoDB native driver. Need to retrieve some documents, and make modification, then save them right back. This is an example:

db.open(function (err, db) {
  db.collection('foo', function (err, collection)...

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

How to add users in RailwayJS?

I'm using RailwayJS, a Node.JS MVC framework based on ExpressJS, fully ExpressJS-compatible. I'm trying to figure out how to add/generate users, but couldn't find any documentation about it. Does anybody know how?

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

Problems with RailwayJS (node.js): Redis connection to localhost:6379 failed - connect ECONNREFUSED

I found this web framework for node.js similar to Rails: http://railwayjs.com/

I followed all the steps:

sudo npm install railway -g

railway init blog && cd blog
npm install -l
railway generate crud post title content
# ensure mongodb is...

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

What caching is enabled by default when using Express and Mongoose

I seem to be having old extraneous results that are polluting database queries I make. What kind of caching is enabled for the stack Express.js > Mongoose.js? Is there a way to disable it or clear it?

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

Authentication solutions for Node.js

Are there any robust authentication libraries for node.js as for rails (devise, sorcery), that could allow to do external authentication (facebook connect, twitter...) as well?

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

How can I optimize routes in Express.JS?

I have many routes like:

app.all('/:controller', controller.init());
app.all('/:controller/:action', controller.init());
app.all('/:controller/:action/:par1', controller.init());
app.all('/:controller/:action/:par1/:par2',...

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

How do I install package.json dependencies in the current directory using npm

I have a web app: fooapp. I have a package.json in the root. I want to install all the dependencies in a specific node_modules directory. How do I do this?

What I want

Lets say I have two widget dependencies. I want to end up with a directory...

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

Do I need to specify all the host for replica Set in Mongoose, Express-session-mongo and mongolian?

I have MongoDB replica Set as:

Host1: 10.10.10.1:27017
Host2: 10.10.10.1:27018
Host3: 10.10.10.2:27017
Host4: 10.10.10.2:27018

When I set the connection (e.g. IN Mongoose), I have to do...

Read the entire recipe Recipe added 1 day ago