getting started with developing nodejs

Post on 01-Sep-2014

5.972 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

An introduction to developing with Node.js and some useful tools to help the development and deployment processes. This talk was given at Asyncjs in Brightonhttp://asyncjs.com/intro-nodejs

TRANSCRIPT

node.jsyet another talk on

getting started

@philhawksworth

what we’ll look atwhaddizit?

installation optionshello world

modules & frameworksdeploying & hostingcomet and beyond

assumptions

web development experiencejavascript knowledge

unix, linux, osxnot a nodejs ninja

whaddizit?

Evented I/O forV8 Javascript

c++v8 javascript engine

server-side javascriptsingle event loop

non-blocking

evented i-what now?

strong javascriptjQuery patterns

useful knowledge

jQuery patternsdangerous knowledge

considerationshow mature is it?

v0.0.1: early 2009, currently v.0.4.8

who uses it?everyone is playing.

considerationshow mature is it?

v0.0.1: early 2009, currently v.0.4.8

who uses it?everyone is playing.

should I be scared of it?no. but be cautious.

ball-ache:stability

rate of change

installation options

build from sourcepackage

ndistron

from sourceclone source from github

install dependanciesxcode tools

configure, make, make install

package

ball-ache:stability

rate of change

many versionsmany versionsmany versionsmany versionsmany versionsndistro & n

ndistro node distribution toolkit

enables many versions of node

http://github.com/visionmedia/ndistro

http://github.com/visionmedia/ndistro

local versions for each project

n

install as a module

ball-acheversion stabilitymodule stability

installing modules

npmnode package manager

curl http://npmjs.org/install.sh | sh

$ npm install <package>

$ npm install n

$ npm install n@0.4.1

$ npm ls

$ npm update n

$ npm install n

$ npm update npm

n

while ndistro is for virtual

environments

while ndistro is for local

environments

n gives system wide

node versioning

$ n 0.2.6$ n v0.3.3

downloadconfigure

make install

$ n ls

$ n

0.2.3 0.2.6 --debug 0.3.4 0.3.5ο 0.4.8

$ n use 0.4.8

what we’ll look atwhaddizit?

installation optionshello world

modules & frameworksdeploying & hostingcomet and beyond

hello world

hello world

app.js

$ node app.js

$ ./bin/node app.js

$ n use 0.4.8 app.js

frameworksget a little help

uri routingcontent negotiation

templatingenvironment configuration

expressthe canonical web

development frameworkhttp://expressjs.com

bootstrappingquick scaffolding

$ express --template --css --session

$ n use 0.4.8 app.js

deployingwhere do I put this thing?

self-managedamazon, linode, slicehost

managedheroku, no.de

automated, git-based deployment

install via npm

manage dependancies via npm

limited versions of nodejs

duostack

hello world

server.js

$ git init$ git add$ git commit -m ‘1st commit’

$ duostack create nodedemo$ git push duostack master

Delta compression using up to 2 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 416 bytes, done.Total 3 (delta 0), reused 0 (delta 0)

==== Duostack deploy received for nodedemo==== Compiling app... done Compressed size is 4.0KB==== Launching first instances.... done

==== App successfully deployed to==== http://nodedemo.duostack.net

self-managedamazon, linode, slicehost

deployingget it there

git

configure itinstall dependencies

get it up, and keep it upupstart

$ git clone project.git$ cd project$ ndistro

ndistro is really just the shell

replicates your environment

keeping it up

$ /etc/init.d/

http://upstart.ubuntu.com/

what we’ll look atwhaddizit?

installation optionshello world

modules & frameworksdeploying & hostingcomet and beyond

easy comet requests

websockets

cometlong-lived http requests

javascript on the clientasks, and listens

asks again, or takes action

websocketsmore efficient low latency comms

supported in modern browsers

Graceful degradation

WebSocketAdobe Flash Socket

Ajax long pollingAjax multipart streaming

Forever IframeJSONP Polling

but...node is not just for realtime

staying in the loop

and finding out more

github wikigithub.com/joyent/node/wiki

github wiki

@ryah@tjholowaychuk

@isaacs@sh1mmer

top related