Intro to Node.js

The power of the third millenium

Created by @ajlopez

https://github.com/ajlopez/Talks/NodeIntro

Using reveal.js

The next big thing!!

since sliced bread

http://www.toaster.org/slicingbread.html

Agenda

  • Node.js
  • Modules
  • NPM package manager
  • Express

Node.js

http://nodejs.org/

Node.js

  • JavaScript Runtime
  • Based on Google V8 JavaScript Engine
  • One thread for JavaScript
  • Asynchronous operations via LibUv
  • Native Modules
  • Module Ecosystem

Traditional Web Server

http://magnetik.github.com/node-webid-report/

Node.js Event Loop

http://magnetik.github.com/node-webid-report/
## A Web Server ```js var http = require('http'); http.createServer(function (req, res) { res.writeHeader(200, {'Content-type': 'text/plain'}); res.write('Hello '); res.end('World'); }).listen(8000); ```

Vibrant Community

NPM

https://www.npmjs.com/

NPM

  • Node Package Manager
  • Description in package.json
  • Install packages in node_modules local folder
  • Tree structure
  • Local vs Global install
## package.json ```json { "name": "wine-cellar", "description": "Wine Cellar Application", "version": "0.0.1", "private": true, "dependencies": { "express": "3.x", "mongodb": "1.1.8", "socket.io": "0.9.x" }, "engines": { "node": "0.8.4", "npm": "1.1.49" } } ```

Express

http://expressjs.com/

Express

  • Web Framework
  • Based on Connect
  • MVC routing and views
  • Minimalist

Node Cellar

More info

The End

BY Angel 'Java' Lopez / www.ajlopez.com / @ajlopez