Latest Node.js Recipes

Understanding Asynchronous Code in Layman's terms

I understand the basic thing about asynchronous-ness: things don't execute sequentially. And I understand there is something very powerful about that... allegedly. But for the life of me I can't wrap my head around the code. Let's take a look at async...

Read the entire recipe Recipe added 39 seconds ago

When installing a package with NPM, can you tell it to use a different version of one of its dependencies?

Say you want to install a library lib-a which has dependencies dep-1 and dep-2. If lib-a has declared in its package.json to use a version of dep-2 that is out of date (say it doesn't work on node 0.8.0 which just came out), but there is a branch of...

Read the entire recipe Recipe added 1 hour ago

What frameworks to use to develop full and secure dynamic web application with node.js?

What frameworks to use to develop dynamic web application with node.js and what books to read or articles? Can you recommend full stack

Read the entire recipe Recipe added 2 hours, 1 minute ago

How do I make a mongoose schema with a set of more than one type?

So I have a schema with people and groups. I want to make it possible for a person to be related to one or more people or groups. So far I have this:

var PersonSchema = new Schema({
    name    : String,
});
var PersonModel = mongoose.model('Person',...

Read the entire recipe Recipe added 3 hours ago

Confused about Expressjs / Nodejs Request - Response handling

Well - the more I read the more confused I get. So here the source:

var express = require('express')
  , http = require('http')
  , server = express()
  ;

var home = require('./routes/home.js')
  , about = require('./routes/about.js')
  , contact =...

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

Can I use Flatiron's resourceful in express?

Is it possible to use Flatiron's resourcefull (ODM) in express.js?

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

What is the difference between node.js https request and XMLHttpRequest?

What is the difference between a HTTPS request sent via node.js module and via XMLHttpRequest?

I am trying to send a HTTPS GET request to amazon aws to get a security token from javascript (XMLHttpRequest) and it always fails with "Origin ...

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

Express.js Middleware - Adding items to the response object model

I'm playing around with Expressjs and am attempting to extract the page title from the default template to middleware instead of passed into the view's model each time.

Default index.jade template

h1= title

p Welcome to the #{title}

Default route...

Read the entire recipe Recipe added 7 hours, 1 minute ago

NodeJS, use Eclipse Debugger for variables inspection?

I'm following https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger and leaves me with questions

  1. How can I see what variables contain?
  2. How can I execute arbitrary commands?

This is similar to webkit's inspector. You can...

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

How can I check if npm packages support Node.js v0.8.x?

I have a deployed version 0.6 of Node.js with a considerable number of packages installed for various projects.

Is there a straight-forward way to check all of the packages that were installed using NPM to see if they support Node.js v 0.8.x?

I can...

Read the entire recipe Recipe added 9 hours ago

Running multiple Node (Express) apps on same port

I have multiple Node applications (build on Express framework).

Now I have placed them like this -

  • /var/www/app1
  • /var/www/app2
  • /var/www/app3

Now I want to run these 3 apps on the same port (say 8080). Is that possible ?

One thing to note is...

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

Heroku does not respect npm-shrinkwrap.json

I have a Node.js app with npm-shrinkwrap.json checked in. When I run npm install locally, it installs the versions specified in npm-shrinkwrap.json, but when I push it to Heroku (on the Cedar stack), it seems to ignore the shrinkwrap and simply...

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

Reading a file in real-time using Node.js

I need to work out the best way to read data that is being written to a file, using node.js, in real time. Trouble is, Node is a fast moving ship which makes finding the best method for addressing a problem difficult.

What I Want To Do
I have a java...

Read the entire recipe Recipe added 12 hours, 1 minute ago

nodejs from 0.6.19 to 0.8.0: App crashes upon start

I'm developing an application (nodejs+mongodb+backbone) and my system runs archlinux. Up until this morning I was on nodejs v 0.6.19-1 and my code ran peacefully.

Then i updated my system and nodejs v 0.8.0 got installed.

Soon after the update I got...

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

Jade not finding view in different folder

I have a directory like this

/Workspace
  /app
    app.js
  /lib
    /public
      /styles
        *.css
      /scripts
        *.js
    /views
      *.jade

from app.js in app, I have the following code:

libPath = __dirname + '/../lib'

......

Read the entire recipe Recipe added 14 hours, 1 minute ago

Update a document collection in MongoDB using Node.js

I am working a twitter like follow model, for which my User's schema is as follows.

var UserSchema = new Schema({ 
    username: {type: String, match: /^[a-zA-Z0-9_]+$/, unique: true}, 
    email: { type: String, unique: true }, 
    password:...

Read the entire recipe Recipe added 15 hours ago

Using LESS with node.js

Less is amazing and I want to use to node.js because using less.js is not a good performance. I testing purpos i'm using xamp on windows and I install node.js but where and what i should write.. I install express.js npm install -g express and less...

Read the entire recipe Recipe added 16 hours, 1 minute ago

What's going on with this Backbone/node/express 400 Bad Request error when deploying to Heroku?

I'm getting a 400 Bad Request error when deploying my Backbone.js/node.js app to Heroku.

From the logs:

Error: Bad Request
    at Object.error (/app/node_modules/express/node_modules/connect/lib/utils.js:42:13)
    at IncomingMessage.<anonymous>...

Read the entire recipe Recipe added 17 hours ago

node.js C addon queueing by uv_queue_work

I have created a C node.js addon with the help of libUV to make the addon asynchronous.

I have made several queues for this.

The code is like this, loopArray is used for storing those queues:

//... variables declarations

void AsyncWork(uv_work_t*...

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

Architecture for Redis cache &amp; Mongo for persistence

The Setup:
Imagine a 'twitter like' service where a user submits a post, which is then read by many (hundreds, thousands, or more) users.

My question is regarding the best way to architect the cache & database to optimize for quick access & many...

Read the entire recipe Recipe added 19 hours, 1 minute ago

Node + Coffeescript + Zappa

I have been looking around for the best framework with nodejs. I am starting to lean twords Zappa. I was testing it out and everything was working fine until I started a new project and reinstalled it with npm.

Now any time I do anything with it, it...

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

Adding more functions to Backbone Models

I am attempting to add some functions to backbone so that I can communicate with mongodb. Now I know this won't work client side; however, I do like backbone's functionality for server side model logic as well. I noticed that I would be doing a bunch...

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

Using older version of Node.js Express Framework

I am experiencing this problem with Node.js express framework 3.0:

https://github.com/visionmedia/express/issues/1187

I've been using express framework 2.0 and am in the process of updating my code to use the next 3.0 framework. In the above link...

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

JS game development libs?

I have a realtime tile set / map strategy style game that I'm building with JavaScript on the client side, however I want to leverage an existing library or libraries that have perhaps thought through some issues more methodically than I'd be able to...

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

How can I return JSON from node.js backend to frontend without reloading or re-rendering the page?

I am working with node.js.

I want to press a search button, make some rest api calls to another server in the backend and return the json back to the front end, and reload a div in the front end so that I won't have to refresh the page. Now I know I...

Read the entire recipe Recipe added 1 day ago