Node.js 201: building real-world applications in pure JavaScript
-
Upload
tom-boutell -
Category
Internet
-
view
219 -
download
0
Transcript of Node.js 201: building real-world applications in pure JavaScript
Node.js 201
building real web and CMS applicationsin pure JavaScript
Tom Boutell @boutell punkave.com
Hello World?
● Goodbye
● Well… how about a simple real app?
10 PRINT “HELLO WORLD”20 GOTO 1030 REM WHO CARES
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
“Node barely does anything”
node event loop
send thingsreceive thingssomething new happens...
your callbacks
do as little as possibleset up more callbacks
node in production (at some scale)
web browser
sends requestsfull 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 (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
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