Node.js beyond web apps

Yours Truly, Geries Handal @gtothesquare

Node.js beyond web apps

Brought to you by Geries Handal

What is this talk about?

Beyond the web: REST, Ajax and HTTP

Node.js Realm - I/O bound programs

Design Principles

build scalable network programs

event driven, non-blocking I/O

callbacks

The Event Loop

source: "Node.js the right way" by Jim M. Wilson

Simplification: First node goes through the javascript code in the load or setup phase. If there is something wrong then it will throw an exception and exit. If all good, then will enter the event loop

CLI

Fundamentals

  1. she bang: #!/usr/bin/env node
    • ./myscript.js
  2. Argument Vector: (process.argv)
  3. Exit the Unix way:
    • process.exit(0);
    • process.exit(1);

more at Daily.js: Unix Node Arguments

Unix and Unix-like systems use a convention that a non-zero exit status from a program is an error.

Modules

Proxies

Usage

  1. JSON - think CouchDB, MongoDB and Postgres > 9.2 (JSON)
  2. Backend Services
  3. Frontend Proxy
  4. Router

source: http://www.nczonline.net/blog/2013/10/07/node-js-and-the-new-web-front-end/

Before - left diagram : frontend was rendered in the server: php, rails, etc. After - right diagram : frontend proxy server, talks to the backend can do what ever they want and frontend can write api and services that satisfy their new requirements: realtime, single page and consume other services.

Modules

For more info, check Strongloop blog:

Comparing Express, Hapi, Restify and loopback

Realtime and Streaming

Realtime

  1. Web Sockets - engine.io, socket.io, etc
  2. Dashboards
  3. Monitoring

More on Websockets

Finding the right Node.js WebSocket implementation

Internet of things

Internet of things

Desktop Apps - node-webkit

General stuff

If you invest in a technology, then invest in people.

Don't use Node for hard computations.. if you must, then queue.(e.g ZeroMQ)

Remember the unix way.

Thanks - Questions?

References and resources