NodeJS 4 years ago

Since I decided to try out NodeJS a week ago i have written two websites (this one, and and on my way to write a HTTP REST service using the Connect framework for replacing the Azure mobile service im using for Studentguiden. I will save money and learn something new. Win-win!

The tools I am using are:


A framework to transform a really simple structure into HTML. For example:
  div.grid-4. Hello :)

Will transform into:

<div class="black-bg center">
  <div class="grid-4">Hello :)</div>

It has some nice syntax for accessing the view-model as well:

  for item in list
      p. #{item.title}

Check out the Jade home page.


Connect is a framework which allows really streamlined middleware implementation into the request pipeline. If that sounds like Greek it is just because it is fancy speak for awesome.

Im only working against Connect directly in my REST service, otherwise I have used Express which is an abstraction over Connect for HTTP services.

A middleware in Connect is just a function:

function(request, response, next) { }

where next is the next middleware in the pipe.

I have written a simple middleware for extracting JSON objects from the body of the request, it is only 8 lines of code. Although is it vulnerable for attacks, e.g. an attacker filling the memory of the server, it is still a great example of how easy Connect is and how powerful it is:

function(req, res, next){
  var body = "";

  req.on('data', function (chunk) {
    body = body + chunk;

  req.on('end', function(){
    req.body = JSON.parse(body);

Check out Connect on GitHub.


Express in an abstraction over Connect aimed at simplifying writing web sites. It has support for view engines and everything else you would expect from a top class framework. It also has a large library of middlewares.

I am using Express for this website ( and also for and the experience has been great. It was easy and quick to find solutions to my problems and it seems to have a good community. You can check out Express on their homepage or on GitHub.

Tweet about this post