1
Node.js Tools Ecosystem
Michael Byrne, MultiValue Evangelist
2
Abstract
 Node.js is a powerful JavaScript platform that helps you build server
applications. It has become a popular option for building network
applications and web servers. Explore how Node.js interacts with the
multitude of add-on open source modules to build a modern web
application in no time.
©2015 Rocket Software, Inc. All Rights Reserved.
3
Agenda
 Intro to Node.js
 Code editors
 Node Package Manager (npm)
 Web server: Express, koa, hapi
 Template engines: Jade / EJS
 Client-side packaging: Bower / Browserify
 Task runners: Grunt / Gulp
 Scaffolding tools: Yo (Yeoman)
 Testing: Jasmine, Mocha, Karma
©2015 Rocket Software, Inc. All Rights Reserved.
4
What is Node.js?
Platform built on Google V8 JavaScript engine
• Open-source under BSD license
• Extremely fast
• Focused on web; proficient with HTTP, DNS, TCP, etc.
Easily build fast, scalable network applications
Asynchronous, event-driven, non-blocking I/O model
Large developer community
©2015 Rocket Software, Inc. All Rights Reserved.
5
Why Are JavaScript and Node.js Relevant?
Incredibly fast – non-blocking programming
Dynamic objects and prototypal inheritance
JavaScript is the internet
Consistent language across stack
Tooling and community
©2015 Rocket Software, Inc. All Rights Reserved.
6
What Enterprises Say
©2015 Rocket Software, Inc. All Rights Reserved.
“Node.js powers our web applications and has allowed our teams
to move much faster in bringing their designs to life”
Jeff Harrell – Director of Engineering at PayPal
“Node’s evented I/O model freed us from worrying about locking and
concurrency issues that are common with multithreaded async I/O”
Subbu Allarmarju – Principal Member, Technical Staff at ebay
“On the server side, our entire mobile software stack is completely
built in Node. One reason wasscale. The second is Node showed us
huge performance gains.”
Kiran Prasad – Mobile Development Lead at LinkedIn
Source: http://apmblog.dynatrace.com/2015/04/09/node-js-is-hitting-the-big-time-in-enterprise-markets/
7
Sample Node.js Architecture
©2015 Rocket Software, Inc. All Rights Reserved.
Web API HTML
MV REST Server
MV DB Server
Web Server
8
Node.js Simple Web Server
©2015 Rocket Software, Inc. All Rights Reserved.
server.js
> Node server.js
Server running at http://127.0.0.1:3000/
9
Code Editors for Web Development
©2015 Rocket Software, Inc. All Rights Reserved.
Brackets
(Free)
Sublime Text
($70 for indiv)
WebStorm
($49 for indiv)
10
Node Package Manager (npm)
Package manager for JavaScript written in JavaScript
Default package manager for Node.js. Auto installed
with Node environment as of v0.6.3. (current v0.12.7)
npm modules are retrieved over the internet from the
public package registry maintained on
http://npmjs.org
©2015 Rocket Software, Inc. All Rights Reserved.
11
npm Overview
©2015 Rocket Software, Inc. All Rights Reserved.
npm
Node.js Project
Installed Packages
12
Npm Usage
©2015 Rocket Software, Inc. All Rights Reserved.
> npm install <package-name> --save --save-exact
{
"dependencies": {
<package-name>: "3.10.1"
}
}
package.json
13
Nodemon
Monitors for changes in files and restarts server
©2015 Rocket Software, Inc. All Rights Reserved.
> npm install –g nodemon
> nodemon server.js
C:demos>node server.js
Server running at http://127.0.0.1:3000/
^C
C:demos>node server.js
Server running at http://127.0.0.1:3000/
^C
C:demos>node server.js
Server running at http://127.0.0.1:3000/
14
Node.js Simple Web Server with Nodemon
©2015 Rocket Software, Inc. All Rights Reserved.
server.js
> Nodemon server.js
Server running at http://127.0.0.1:3000/
15
Express
Minimal and flexible Node.js web application framework
Good for web and mobile applications
Easy to build robust APIs
©2015 Rocket Software, Inc. All Rights Reserved.
> npm install express –-save –-save-exact
16
Web Server with Express
©2015 Rocket Software, Inc. All Rights Reserved.
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
17
Express-generator
©2015 Rocket Software, Inc. All Rights Reserved.
C:demosmvu2015node>express -h
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --ejs add ejs engine support (defaults to jade)
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass) (d
efaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory
18
Template Engines
EJS with Jade templating engine
©2015 Rocket Software, Inc. All Rights Reserved.
19
Bower
©2015 Rocket Software, Inc. All Rights Reserved.
# registered package
$ bower install jquery
# GitHub shorthand
$ bower install desandro/masonry
# Git endpoint
$ bower install git://github.com/user/package.git
# URL
$ bower install http://example.com/script.js
Front-end package manager
20
Express Demo with MV REST API
©2015 Rocket Software, Inc. All Rights Reserved.
21
Sample Node.js Architecture
©2015 Rocket Software, Inc. All Rights Reserved.
MV REST Server
MV DB Server
Web Server
22
Testing Tools
Karma
• Layer on top of testing libraries using common configuration
• Agnostic to testing framework (Jasmine, Mocha, etc.)
• Can test different browser behavior
Jasmine – BDD testing framework
• Frisby – REST API testing framework on Jasmine
Mocha – TDD testing framework
©2015 Rocket Software, Inc. All Rights Reserved.
23
Jasmine Testing Example (no Karma)
©2015 Rocket Software, Inc. All Rights Reserved.
Defined Test (api_spec.js)Route added to index.js
24
Yeoman
Generator ecosystem
Collection of 3 tools
• Scaffolding: Yo
• Build system: Grunt / Gulp
 Minification of JS and CSS
 Build tasks (copy, clean, rename, move, etc.)
 Testing
• Package manager: Bower / npm
 jQuery, AngularJS, Custom Scripts, etc.
©2015 Rocket Software, Inc. All Rights Reserved.
25
Yo Generators
©2015 Rocket Software, Inc. All Rights Reserved.
> yo generator-angular
> Grunt serve
Running "serve" task
Running "clean:server" (clean) task
>> 1 path cleaned.
Running "wiredep:app" (wiredep) task
Running "wiredep:test" (wiredep) task
Running "concurrent:server" (concurrent) task
Running "copy:styles" (copy) task
Copied 1 file
Done, without errors.
Live Reload
26
Popular Generators
©2015 Rocket Software, Inc. All Rights Reserved.
27
Additional Resources
 https://en.wikipedia.org/wiki/Npm_(software)
 https://www.airpair.com/node.js/posts/nodejs-framework-comparison-express-
koa-hapi
©2015 Rocket Software, Inc. All Rights Reserved.
29
Disclaimer
THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.
WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED
IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
IN ADDITION, THIS INFORMATION IS BASED ON ROCKET SOFTWARE’S CURRENT PRODUCT PLANS AND STRATEGY,
WHICH ARE SUBJECT TO CHANGE BY ROCKET SOFTWAREWITHOUT NOTICE.
ROCKET SOFTWARE SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR
OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.
NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:
• CREATING ANY WARRANTY OR REPRESENTATION FROM ROCKET SOFTWARE(OR ITS AFFILIATES OR ITS OR
THEIR SUPPLIERS AND/OR LICENSORS); OR
• ALTERING THE TERMS AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT GOVERNING THE USE OF
ROCKET SOFTWARE.
©2015 Rocket Software, Inc. All Rights Reserved.
30
Trademarks and Acknowledgements
The trademarks and service marks identified in the following list are the exclusive properties of Rocket Software,
Inc. and its subsidiaries (collectively, “Rocket Software”). These marks are registered with the U.S. Patent and
Trademark Office, and may be registered or pending registration in other countries. Not all trademarks owned by
Rocket Software are listed. The absence of a mark from this page neither constitutes a waiver of any intellectual
property rights that Rocket Software has established in its marks nor means that Rocket Software is not owner of
any such marks.
Aldon, CorVu, Dynamic Connect, D3, FlashConnect, Pick, mvBase, MvEnterprise, NetCure,
Rocket, SystemBuilder, U2, U2 Web Development Environment, UniData, UniVerse, and
wIntegrate
Other company, product, and service names mentioned herein may be trademarks or service marks of
others.
©2015 Rocket Software, Inc. All Rights Reserved.
31

Node.js Tools Ecosystem

  • 1.
    1 Node.js Tools Ecosystem MichaelByrne, MultiValue Evangelist
  • 2.
    2 Abstract  Node.js isa powerful JavaScript platform that helps you build server applications. It has become a popular option for building network applications and web servers. Explore how Node.js interacts with the multitude of add-on open source modules to build a modern web application in no time. ©2015 Rocket Software, Inc. All Rights Reserved.
  • 3.
    3 Agenda  Intro toNode.js  Code editors  Node Package Manager (npm)  Web server: Express, koa, hapi  Template engines: Jade / EJS  Client-side packaging: Bower / Browserify  Task runners: Grunt / Gulp  Scaffolding tools: Yo (Yeoman)  Testing: Jasmine, Mocha, Karma ©2015 Rocket Software, Inc. All Rights Reserved.
  • 4.
    4 What is Node.js? Platformbuilt on Google V8 JavaScript engine • Open-source under BSD license • Extremely fast • Focused on web; proficient with HTTP, DNS, TCP, etc. Easily build fast, scalable network applications Asynchronous, event-driven, non-blocking I/O model Large developer community ©2015 Rocket Software, Inc. All Rights Reserved.
  • 5.
    5 Why Are JavaScriptand Node.js Relevant? Incredibly fast – non-blocking programming Dynamic objects and prototypal inheritance JavaScript is the internet Consistent language across stack Tooling and community ©2015 Rocket Software, Inc. All Rights Reserved.
  • 6.
    6 What Enterprises Say ©2015Rocket Software, Inc. All Rights Reserved. “Node.js powers our web applications and has allowed our teams to move much faster in bringing their designs to life” Jeff Harrell – Director of Engineering at PayPal “Node’s evented I/O model freed us from worrying about locking and concurrency issues that are common with multithreaded async I/O” Subbu Allarmarju – Principal Member, Technical Staff at ebay “On the server side, our entire mobile software stack is completely built in Node. One reason wasscale. The second is Node showed us huge performance gains.” Kiran Prasad – Mobile Development Lead at LinkedIn Source: http://apmblog.dynatrace.com/2015/04/09/node-js-is-hitting-the-big-time-in-enterprise-markets/
  • 7.
    7 Sample Node.js Architecture ©2015Rocket Software, Inc. All Rights Reserved. Web API HTML MV REST Server MV DB Server Web Server
  • 8.
    8 Node.js Simple WebServer ©2015 Rocket Software, Inc. All Rights Reserved. server.js > Node server.js Server running at http://127.0.0.1:3000/
  • 9.
    9 Code Editors forWeb Development ©2015 Rocket Software, Inc. All Rights Reserved. Brackets (Free) Sublime Text ($70 for indiv) WebStorm ($49 for indiv)
  • 10.
    10 Node Package Manager(npm) Package manager for JavaScript written in JavaScript Default package manager for Node.js. Auto installed with Node environment as of v0.6.3. (current v0.12.7) npm modules are retrieved over the internet from the public package registry maintained on http://npmjs.org ©2015 Rocket Software, Inc. All Rights Reserved.
  • 11.
    11 npm Overview ©2015 RocketSoftware, Inc. All Rights Reserved. npm Node.js Project Installed Packages
  • 12.
    12 Npm Usage ©2015 RocketSoftware, Inc. All Rights Reserved. > npm install <package-name> --save --save-exact { "dependencies": { <package-name>: "3.10.1" } } package.json
  • 13.
    13 Nodemon Monitors for changesin files and restarts server ©2015 Rocket Software, Inc. All Rights Reserved. > npm install –g nodemon > nodemon server.js C:demos>node server.js Server running at http://127.0.0.1:3000/ ^C C:demos>node server.js Server running at http://127.0.0.1:3000/ ^C C:demos>node server.js Server running at http://127.0.0.1:3000/
  • 14.
    14 Node.js Simple WebServer with Nodemon ©2015 Rocket Software, Inc. All Rights Reserved. server.js > Nodemon server.js Server running at http://127.0.0.1:3000/
  • 15.
    15 Express Minimal and flexibleNode.js web application framework Good for web and mobile applications Easy to build robust APIs ©2015 Rocket Software, Inc. All Rights Reserved. > npm install express –-save –-save-exact
  • 16.
    16 Web Server withExpress ©2015 Rocket Software, Inc. All Rights Reserved. var express = require('express'); var app = express(); app.get('/', function (req, res) { res.send('Hello World!'); }); var server = app.listen(3000, function () { var host = server.address().address; var port = server.address().port; console.log('Example app listening at http://%s:%s', host, port); });
  • 17.
    17 Express-generator ©2015 Rocket Software,Inc. All Rights Reserved. C:demosmvu2015node>express -h Usage: express [options] [dir] Options: -h, --help output usage information -V, --version output the version number -e, --ejs add ejs engine support (defaults to jade) --hbs add handlebars engine support -H, --hogan add hogan.js engine support -c, --css <engine> add stylesheet <engine> support (less|stylus|compass) (d efaults to plain css) --git add .gitignore -f, --force force on non-empty directory
  • 18.
    18 Template Engines EJS withJade templating engine ©2015 Rocket Software, Inc. All Rights Reserved.
  • 19.
    19 Bower ©2015 Rocket Software,Inc. All Rights Reserved. # registered package $ bower install jquery # GitHub shorthand $ bower install desandro/masonry # Git endpoint $ bower install git://github.com/user/package.git # URL $ bower install http://example.com/script.js Front-end package manager
  • 20.
    20 Express Demo withMV REST API ©2015 Rocket Software, Inc. All Rights Reserved.
  • 21.
    21 Sample Node.js Architecture ©2015Rocket Software, Inc. All Rights Reserved. MV REST Server MV DB Server Web Server
  • 22.
    22 Testing Tools Karma • Layeron top of testing libraries using common configuration • Agnostic to testing framework (Jasmine, Mocha, etc.) • Can test different browser behavior Jasmine – BDD testing framework • Frisby – REST API testing framework on Jasmine Mocha – TDD testing framework ©2015 Rocket Software, Inc. All Rights Reserved.
  • 23.
    23 Jasmine Testing Example(no Karma) ©2015 Rocket Software, Inc. All Rights Reserved. Defined Test (api_spec.js)Route added to index.js
  • 24.
    24 Yeoman Generator ecosystem Collection of3 tools • Scaffolding: Yo • Build system: Grunt / Gulp  Minification of JS and CSS  Build tasks (copy, clean, rename, move, etc.)  Testing • Package manager: Bower / npm  jQuery, AngularJS, Custom Scripts, etc. ©2015 Rocket Software, Inc. All Rights Reserved.
  • 25.
    25 Yo Generators ©2015 RocketSoftware, Inc. All Rights Reserved. > yo generator-angular > Grunt serve Running "serve" task Running "clean:server" (clean) task >> 1 path cleaned. Running "wiredep:app" (wiredep) task Running "wiredep:test" (wiredep) task Running "concurrent:server" (concurrent) task Running "copy:styles" (copy) task Copied 1 file Done, without errors. Live Reload
  • 26.
    26 Popular Generators ©2015 RocketSoftware, Inc. All Rights Reserved.
  • 27.
    27 Additional Resources  https://en.wikipedia.org/wiki/Npm_(software) https://www.airpair.com/node.js/posts/nodejs-framework-comparison-express- koa-hapi ©2015 Rocket Software, Inc. All Rights Reserved.
  • 28.
    29 Disclaimer THE INFORMATION CONTAINEDIN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN ADDITION, THIS INFORMATION IS BASED ON ROCKET SOFTWARE’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY ROCKET SOFTWAREWITHOUT NOTICE. ROCKET SOFTWARE SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF: • CREATING ANY WARRANTY OR REPRESENTATION FROM ROCKET SOFTWARE(OR ITS AFFILIATES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS); OR • ALTERING THE TERMS AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT GOVERNING THE USE OF ROCKET SOFTWARE. ©2015 Rocket Software, Inc. All Rights Reserved.
  • 29.
    30 Trademarks and Acknowledgements Thetrademarks and service marks identified in the following list are the exclusive properties of Rocket Software, Inc. and its subsidiaries (collectively, “Rocket Software”). These marks are registered with the U.S. Patent and Trademark Office, and may be registered or pending registration in other countries. Not all trademarks owned by Rocket Software are listed. The absence of a mark from this page neither constitutes a waiver of any intellectual property rights that Rocket Software has established in its marks nor means that Rocket Software is not owner of any such marks. Aldon, CorVu, Dynamic Connect, D3, FlashConnect, Pick, mvBase, MvEnterprise, NetCure, Rocket, SystemBuilder, U2, U2 Web Development Environment, UniData, UniVerse, and wIntegrate Other company, product, and service names mentioned herein may be trademarks or service marks of others. ©2015 Rocket Software, Inc. All Rights Reserved.
  • 30.