Node.js 201
building real web and CMS applications
in pure JavaScript
Tom Boutell @boutell punkave.com
Hello World?
● Goodbye
● Well… how about a simple real app?
10 PRINT “HELLO WORLD”
20 GOTO 10
30 REM WHO CARES
bike-me-now
a simple mobile web app for Philly’s rideindego bike sharing system
bike-me-now.boutell.com
● built with Nick Weber at Code For Philly
● basic express server with a route
● also static server
● request module for talking to APIs
● lodash filtering
web browser
sends requests
full pages, ajax
node process
serves requests
“node is the webserver” (*)
“Node barely does anything”
node event loop
send things
receive things
something new happens...
your callbacks
do as little as possible
set up more callbacks
node in production (at some scale)
web browser
sends requests
full pages, ajax
node process
does dynamic things
nginx
(or apache, or…)
node process
does dynamic things
static files
dynamic
filesystem
static files
load balancing
salsadelphia.com
a directory of upcoming salsa nights
source code:
https://github.com/boutell/salsadelphia
salsadelphia.com
● for philly’s salsa dance community
● facebook authentication with passport
● middleware
● mongodb
● more lodash filtering
livin’ the async life
● the “async” npm module
● series, each, eachSeries, eachLimit
● sublimetext snippets
● alternatives: promises, async functions
creating command line tools
● prettiest: persistence and locking
● mechanic: manage nginx with node
○ higher level tools = good
○ sometimes it’s OK to be synchronous
orbweaver holodeck
orbweaver (npm module)
● a simple but robust web crawler
● parallel accesses
● simulating users
● async.queue
● holodeck (also an npm module)
express-cache-on-demand
● mind-bending middleware
● shortest possible cache lifetime
● use in website projects
● in npm
kickshirts
● crawls kickstarter
● cheerio: lightweight jQuery for the server
● extracting data with familiar techniques
● no longer running, but open source
● https://github.com/punkave/kickshirts
apostrophenow.org
● apostrophe: an open source node CMS
● the sandbox project
● working with schemas
● adding new content types
● areas, singletons and templates
stagecoach
● simple deployment system
● multicore support
● github.com/punkave/stagecoach
uploadfs (in npm)
● uploaded files have to go somewhere
● filesystem back end
● Amazon S3 back end
● transparent in Apostrophe
browserify: node(ish) in the browser
● async-merge-sort module
○ people as comparison functions
● “guided search” example
● limitations of browserify
Thanks!
http://punkave.com/
http://justjs.com/
http://apostrophenow.org/
@boutell

Node.js 201: building real-world applications in pure JavaScript