/node-rd

Code related to the Node.js RD planned for March 22, 2012

Primary LanguageJavaScript

Node.js RD 2012-03-22

Instructions, code snippets, demos and labs for the Node.js RD held at the Crisp office in Stockholm on March 22nd 2012.

Presentation

Intro

Lab 1 (Echo Query Parameter Web Server)

Really Old JavaScript RD might be helpful as a refresher, and this one.

Create a Web Server that responds with the query parameters passed as JSON strings. Example response:

$ curl -i "http://localhost:3000/?p=xxx&xxx=p"
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive
Transfer-Encoding: chunked

{ p: 'xxx', xxx: 'p' }

Some hints can be found in labs/lab1-web-server/server.js.

Lab 2 (testing with nodeunit)

npm install -g nodeunit
cd labs/lab2-nodeunit
nodeunit test

Depending on your OS you may need to sudo (or equivalent) the npm install command.

Lab 3 (chat server)

Create a Chat Server where each socket is identified by an id of the form id-[count].

Possibly Helpful

  • net api
  • JavaScript is a dynamic language.

Lab 4 (web server with Express)

npm install -g express
mkdir labs/lab4-express
cd labs/lab4-express
express --help

Depending on your OS you may need to sudo (or equivalent) the npm install command.

Create a web application using the express executable, template engine ejs, no session support and plain css.

Lab 5 (socket.io)

npm install -g socket.io
mkdir labs/lab5-socket.io
cd labs/lab5-socket.io

Create a browser based chat application using socket.io. A starting point can be found in labsolutions/lab5-socket.io

Useful links

References