I prefer not to write blog post showing coding samples. They tend to go stale and lose relevance quickly. Instead, I publish sample apps to GitHub with pretty damn good documentation. You can pull these apps down, build and run them yourself.
If you want to learn NodeJS, the resources below will help you.
These apps are ordered by complexity/difficulty.
The apps are all released under MIT or Creative Commons Non-Commercial.
All have readmes that will guide you in building, running and deloying the apps.
If you find a problem with any of these apps, open a GitHub issue. Or even better, send me a pull request with updates.
Search the entire english dictionary for words that match a specfic pattern. Great little website that will “help” you in games such as Words with Friends.
This app is a pretty bare bones app. There is enough non-trival code in here for you to get a grasp on the structure of a NodeJS app and how you can do something useful with the platform. It uses a lean and powerful web framwork called
express and a light weight templating engine called
Libraries used: express, ejs
A simple chat app. Each person that comes to the page gets assigned the name of a celebrity. You can chat with each other. Role play. Keep it PG.
This app shows, what I feel, is the killer feature of NodeJS: websockets. The code is fairly simple. It exchanges a few messages with server and client in realtime. The libraries used are
ejs and a websockets library called
Libraries used: express, ejs, socket.io
A todo list. Add, update items. Mark them as done.
This app shows one of many ways you can persist data in NodeJS. It uses an extremely fast, in memory key value data store called
redis. After understanding this app (and the two apps above), you’ll have everything you need to start building web applications using NodeJS: web framework, realtime communciation with websockets, and a way to save data.
Libraries used: express, ejs, redis
A Pomodoro client with a text messaging interface. The Pomodoro Technique is used for time management.
Libraries used: express, ejs, redis, angularjs, twilio, underscore
This app is a twitter client with a two phase authorization scheme (password and text). It allows you to search and add additional metadata to tweets. Read the readme for more information.
This app shows a non-trivial use of
redis and a front end framework called
angularjs. You’ll also learn how to leverage Twitter’s REST Api’s and Twilio, a service that allows you to send text messages. There is a lot of comments in this code base. Read the source for more information.
Libraries used: express, ejs, redis, angularjs, twilio, underscore, oauth, request
This is a port of the game Cards Against Humanities. It’s released under Creative Commons Non-Commercial.
This app shows a non-trival (but still simple) usage of
socket.io. It’s also mobile friendly and has fallbacks in place for clients that have a “not so reliable” internet connection. There is also a test suite associated with this code base using a library called
Libraries used: express, ejs, underscore, socket.io, jasmine-node
This is a real time, multiplayer fighting game currently hosted here. This codebase is a cleaned up version of what our team built for Node Knockout 2013. Out of 385 teams, we placed 15th overall and 6th in the “fun/utility” category.
The app shows a non-trivial usage of
socket.io and a HTML5 canvas framework called
pixijs. The app shows how you can share common code on the server and client (in this case the physics engine).
in a class centric format vs a functional format). The commit history is fairly clean. Step through the commit history to see how the app evolved over time.
Libraries used: express, ejs, underscore, socket.io, jasmine-node, pixijs.