Node.js app from scratch - What is Node?

08 Sep 2013

This is my first attempt at a web app in Node.js (from scratch).

I have used the Express framework before, and I didn't like it because I don't know a lot about Node. I can't distinguish where it draws the line and Express comes in.

This raises the question, what exactly is Node? and how can it help me create a high quality web application? Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. (nodejs.org, 2013)

That's great, but what the hell does it do? Where does it fit in a web app ecosystem? I hope to answer those questions by the end of this series.

Where I'm at

I'm having a hard time figuring out how to serve a simple index file (I bet it's easier to achieve data persistency).

One of the examples found in nodejs.org runs a web server that returns an HTTP response with "Hello world":

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
})

From this code it's evident that Node serves a response, and it's our job to build that response. I chose to do it from scratch (sigh).

The first thing I want to do in order to get more familiar with Node is to serve a calendar-like view for the days of the week, with the hours of each day. I'll build that as standard HTML and then render it using Node.

Next - Getting started