Tuesday, November 24th, 2009

Node and Djangode Follow-Up

Category: Node, Server

Simon Willison’s Talk last week on Node generated a healthy dose of post-conference buzz, and he’s followed up with a blog post on Node and his higher-level API for Node, Djangode.

Node’s core APIs are pretty low level—it has HTTP client and server libraries, DNS handling, asynchronous file I/O etc, but it doesn’t give you much in the way of high level web framework APIs. Unsurprisingly, this has lead to a cambrian explosion of lightweight web frameworks based on top of Node—the projects using node page lists a bunch of them. Rolling a framework is a great way of learning a low-level API, so I’ve thrown together my own—djangode—which brings Django’s regex-based URL handling to Node along with a few handy utility functions.


  1. var dj = require('./djangode');
  3. var app = dj.makeApp([
  4.   ['^/$', function(req, res) {
  5.     dj.respond(res, 'Homepage');
  6.   }],
  7.   ['^/other$', function(req, res) {
  8.     dj.respond(res, 'Other page');
  9.   }],
  10.   ['^/page/(\\d+)$', function(req, res, page) {
  11.     dj.respond(res, 'Page ' + page);
  12.   }]
  13. ]);
  14. dj.serve(app, 8008);

Pretty simple, and gets a whole lot more interesting when he shows how to build a simple Comet server with this API. He also covers database access, where there’s a good fit between server-side Javascript and the NOSQL servers that speak HTTP and JSON.

His article also provides a nice overview of Node itself, along with some straightforward install instructions.

At first glance, Node looks like yet another take on the idea of server-side JavaScript, but it’s a lot more interesting than that. It builds on JavaScript’s excellent support for event-based programming and uses it to create something that truly plays to the strengths of the language.

Node describes itself as “evented I/O for V8 javascript”. It’s a toolkit for writing extremely high performance non-blocking event driven network servers in JavaScript. Think similar to Twisted or EventMachine but for JavaScript instead of Python or Ruby.

Posted by Michael Mahemoff at 9:53 am
Comment here

3.8 rating from 29 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.