Thursday, July 25, 2013

OSCON Adventures in Node.js

The Adventures in Node.js page on OSCON.

Faisal Abid (Dynamatik, Inc.)
2:30pm Thursday, 07/25/2013

node.js is built around "events"
event loop is always running checking for new events
fires callbacks when new events are received

http.createServer(function(request, response) {
    // request has all information about request
    // response allows packaging of what will be returned to client.


use EventEmitter class to write custom events
 - can help with callback hell

require is used to import modules to your application.
- modules are like classes
- http module is stored in the node_modules folder
- require returns a JSON object

in examples using nodemon

npm is used to get modules -
run from cmd line:
npm install
npm install nodemon
npm install -g coffee-script

package.json is a manifest for node
"npm install" will read package and work out and download required packages
use * in package to get latest version otherwise specify version number
npm install --save hbs - adds to package.json?

- framework like sinatra
- REST API for node
- great support for templates
- templates: Jade, EJS, Dust (LinkedIn now owns Dust)

restangular - simplify rest on angular

node has 32k modules out there, huge community support

No comments:

Post a Comment