the new swiss army chainsaw

Nicole Oliver, Full-stack Developer

Jude Poole, Director of Computer Services

Division of Biological Sciences, UC San Diego

 is A Runtime Environment for

server-side and networking applications

  • runs JS from the command line
  • has access to local file system
  • uses Google V8 Javascript engine

open source & cross-platform

Characteristics

  • single-threaded, asynchronous
  • event-driven architecture
  • non-blocking I/O API
  • handles serverside scripting AND is a runtime environment
  • large, active community of developers

History

developed by Ryan Dahl at

 

 

npm added

native windows version created

io.js fork created

io.js and Node.js agree to work together under Node.js Foundation

Modules

  • core
  • distributed
  • custom - build your own!

the building blocks of your project

NPM (JS package manager)

the most modules of

any module registry,

by any measure,

for any programming language*

* just over 160,000 at the time of this presentation!

Javascript

  • all web developers know at least a little javascript!
  • new features in ECMAScript 2015

the world's most misunderstood programming language?

Same language: CLIENT AND SERVER

  • use same libraries (e.g. underscore)
  • share code (simplify validation)
  • easily use JSON to pass data back & forth

Node kicks butt For...

  • prototyping
  • data intensive real-time (DIRTy) applications
  • push technology over WebSockets
  • rich client frameworks - Angular.js, Ember.js

who uses node.js?

Node.js in Action

  • configuration
  • simple web server
  • Express web server
  • Grunt- task runner
  • nw.js
  • WebSockets
  • authentication

COnfiguration

package.json contains your basic project info

// create new package.json
npm init

// run file
node index.js

// add a dependency and save to package.json
npm install package-name --save

simple web server

'http' is one of the core modules

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Oh hi Lisa!\n');
}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');

Express server

  • Express application generator (scaffolding tool)
  • Jade template engine
// install express application generator tool globally
npm install express-generator -g

// create app skeleton in a new directory called myappname
express myappname

// go into newly created directory and install dependencies
cd myappname
npm install

Grunt Task Runner

  • watch for (and run tasks on) file changes
  • jshint to validate files
  • compile source files - CSS, templates
  • minify/concatenate - js, css, html, images
  • unit testing

 to manage a complex tool chain

Nw.js*

  • Webkit engine (Chromium) + node.js
  • From Intel Open Source Tech Center
  • Linux, OS X and Windows
  • Easy way to create cross platform graphical applications
  • Electron (Atom.io) is a related alternative

* formerly known as node-webkit

WebSockets

  • Real time two way communication
  • Not node specific but node libraries like socket.io make it very easy
  • We believe this technology will be critical for managing multiple people viewing and editing the same data simultaneously in web applications

Auth

  • Standard tool in the Node world is the Passport library
  • Generic interface with implementation “strategies”
  • 300+ strategies currently available including all usual suspects (Facebook, Twitter, Google, etc)
  • Biological Sciences is working on several approaches w/ UCSD SSO
    • Reverse proxy via apache (like typical Tomcat) – working
    • SAML2 Passport strategy (working in test, final steps soon on production)
    • Custom strategy linked to our java/tomcat stack -- planned

our TOp 8 favorite modules

  • underscore
    
  • nodemon
  • grunt
  • forever
  • mysql
  • yo
  • bower
  • express
  • passport

Nicole oliver

nicoliver@ucsd.edu

Let's keep talking!

Jude Poole

jude@ucsd.edu

Full-stack Developer

Division of Biological Sciences

Director of Computer Services

Division of Biological Sciences

References (and some other cool stuff we couldn't fit into this talk) are available:

https://unknotted.ucsd.edu/?p=207​

This presentation was created with reveal.js, an html presentation framework built on node.js!

Node.js: The New Swiss Army Chainsaw

By Nicole Oliver

Node.js: The New Swiss Army Chainsaw

A fast-paced overview of the wildly popular Node.JS platform, with demos and discussion of key usage scenarios in traditional web applications, emerging web technologies like WebSockets, and (time permitting) outside of the web.

  • 2,096