29
Node.js, MongoDB and You: Part II Mitch Pirtle jsDay 2014, Verona Italy - @jsdayit

MongoDB, Node.js And You: PART II

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

Page 1: MongoDB, Node.js And You: PART II

Node.js, MongoDB and You: Part II

Mitch Pirtle jsDay 2014, Verona Italy - @jsdayit

Page 2: MongoDB, Node.js And You: PART II

How many of you watched the first talk?

Page 3: MongoDB, Node.js And You: PART II

Ok how many of you are new to Node?

Page 4: MongoDB, Node.js And You: PART II

What language do you mainly work with?

Page 5: MongoDB, Node.js And You: PART II

Now about me.

Page 6: MongoDB, Node.js And You: PART II

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

Ok my Javascript totally sucks.

Page 8: MongoDB, Node.js And You: PART II

About this talk.

Page 9: MongoDB, Node.js And You: PART II

Ok, technically there are three talks today.

Page 10: MongoDB, Node.js And You: PART II

• 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

Introducing:

Page 12: MongoDB, Node.js And You: PART II

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

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

What do you mean, operational perspective?

Page 15: MongoDB, Node.js And You: PART II

TO THE CONSOLE

Page 16: MongoDB, Node.js And You: PART II

Ok so what does it look like?

Page 17: MongoDB, Node.js And You: PART II

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

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

TO THE CONSOLE

Page 20: MongoDB, Node.js And You: PART II

But wait, there’s more.

Page 21: MongoDB, Node.js And You: PART II

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

MOAR CONSOLE

Page 23: MongoDB, Node.js And You: PART II

Now for the pain.

Page 24: MongoDB, Node.js And You: PART II
Page 25: MongoDB, Node.js And You: PART II

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

Remember: You have to master the asynchronous

nature of javascript.

Page 27: MongoDB, Node.js And You: PART II

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

Stump the Geek™

Page 29: MongoDB, Node.js And You: PART II

Thanks!

• AboutMe

• @mitchitized - Twitter

• spacemonkey - GitHub

• LinkedIn - I’M AVAILABLE!