MongoDB, Node.js And You: PART II
-
Upload
mitch-pirtle -
Category
Technology
-
view
550 -
download
2
description
Transcript of MongoDB, Node.js And You: PART II
![Page 1: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/1.jpg)
Node.js, MongoDB and You: Part II
Mitch Pirtle jsDay 2014, Verona Italy - @jsdayit
![Page 2: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/2.jpg)
How many of you watched the first talk?
![Page 3: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/3.jpg)
Ok how many of you are new to Node?
![Page 4: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/4.jpg)
What language do you mainly work with?
![Page 5: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/5.jpg)
Now about me.
![Page 6: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/6.jpg)
Mitch Pirtle
• Recovering Joomla! founder
• Mongo Master
• Starting companies since 1995
• Musician, skate punk, football coach
• American idiot living in Turin
![Page 7: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/7.jpg)
Ok my Javascript totally sucks.
![Page 8: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/8.jpg)
About this talk.
![Page 9: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/9.jpg)
Ok, technically there are three talks today.
![Page 10: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/10.jpg)
• Session 1: All about MongoDB (you missed it)
• Session 2: All about Node.js (right now)!
• Session 3: The coolness of both together (next)
![Page 11: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/11.jpg)
Introducing:
![Page 12: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/12.jpg)
Big Node.js things
• Completely javascript based.
• Asynchronous.
• Crazy, whack-daddy fast.
• You gotta learn javascript anyway.
![Page 13: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/13.jpg)
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
![Page 14: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/14.jpg)
What do you mean, operational perspective?
![Page 15: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/15.jpg)
TO THE CONSOLE
![Page 16: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/16.jpg)
Ok so what does it look like?
![Page 17: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/17.jpg)
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/');
![Page 18: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/18.jpg)
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');
![Page 19: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/19.jpg)
TO THE CONSOLE
![Page 20: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/20.jpg)
But wait, there’s more.
![Page 21: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/21.jpg)
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)
![Page 22: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/22.jpg)
MOAR CONSOLE
![Page 23: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/23.jpg)
Now for the pain.
![Page 24: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/24.jpg)
![Page 25: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/25.jpg)
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.
![Page 26: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/26.jpg)
Remember: You have to master the asynchronous
nature of javascript.
![Page 27: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/27.jpg)
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
![Page 28: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/28.jpg)
Stump the Geek™
![Page 29: MongoDB, Node.js And You: PART II](https://reader033.fdocuments.net/reader033/viewer/2022042518/554f6046b4c905bb178b469b/html5/thumbnails/29.jpg)
Thanks!
• AboutMe
• @mitchitized - Twitter
• spacemonkey - GitHub
• LinkedIn - I’M AVAILABLE!