Upload
mitch-pirtle
View
550
Download
2
Tags:
Embed Size (px)
DESCRIPTION
This is the second of a three-part series on MongoDB and Node.js at jsDay in Verona Italy 2014.
Citation preview
Node.js, MongoDB and You: Part II
Mitch Pirtle jsDay 2014, Verona Italy - @jsdayit
How many of you watched the first talk?
Ok how many of you are new to Node?
What language do you mainly work with?
Now about me.
Mitch Pirtle
• Recovering Joomla! founder
• Mongo Master
• Starting companies since 1995
• Musician, skate punk, football coach
• American idiot living in Turin
Ok my Javascript totally sucks.
About this talk.
Ok, technically there are three talks today.
• Session 1: All about MongoDB (you missed it)
• Session 2: All about Node.js (right now)!
• Session 3: The coolness of both together (next)
Introducing:
Big Node.js things
• Completely javascript based.
• Asynchronous.
• Crazy, whack-daddy fast.
• You gotta learn javascript anyway.
More Node.js things
• Express is the most common framework
• Many others to choose from
• Excellent from an operational perspective
• Great build tools for css and assets
What do you mean, operational perspective?
TO THE CONSOLE
Ok so what does it look like?
Most simple example
var http = require('http');http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n');}).listen(1337, '127.0.0.1');console.log('Server running at http://127.0.0.1:1337/');
This one repeats what it hears
var net = require('net');!var server = net.createServer(function (socket) { socket.write('Echo server\r\n'); socket.pipe(socket);});!server.listen(1337, '127.0.0.1');
TO THE CONSOLE
But wait, there’s more.
Many frameworks and stacks to choose from
• Express - the most common framework for Node
• MEAN.js - MongoDB, Express, AngularJS and Node
• ng-kickstarter - Better hooks for developers (SASS, Zurb, Grunt, API proxy, and more)
MOAR CONSOLE
Now for the pain.
Asynchronous
• Well that was not intuitive.
• You spend a lot of time making asynchronous code act like a synchronous application.
• You’re doin’ it RONG.
Remember: You have to master the asynchronous
nature of javascript.
There’s plenty of docs!• …from eight months ago
• …that are no longer functional
• …and probably didn’t work very well back then
• Today’s blog post is tomorrow’s broken example
• When stack overflow is your go-to resource, there’s a problem
Stump the Geek™
Thanks!
• AboutMe
• @mitchitized - Twitter
• spacemonkey - GitHub
• LinkedIn - I’M AVAILABLE!