How can node.js help me today?

Michael K. Snead

Let's get on the same page...

JavaScript is the future

  • Modern web applications demand rich client-side functionality
  • JavaScript is the lingua franca of the web
  • As craftsmen of our trade, we need to hold JavaScript development to the same standards as our (other) server side code

node.js is awesome

 node is v8

node is async

node.js is awesome

node is more than just a web server

Twitter Bower (http://bower.io)

Grunt (http://gruntjs.com)

Gulp (http://gulpjs.com)

node.js is awesome

node.js is in the enterprise

Who are you?

  • I can use node.js
  • We can use node.js in development
  • We can use node.js in continuous integration
  • We can use node.js in production

I can use node.js

I can use node.js for...

  • Unit testing JavaScript code
  • Linting JavaScript code
  • Local CI
  • Transpiling
    (Sassy CSS, Traceur, CoffeeScript, etc.)
  • Functional Testing
    (ie: Selenium)
  • Gulp, grunt, etc. through VS

How to use Selenium + node

  • Download the Chrome WebDriver
    http://chromedriver.storage.googleapis.com/index.html
  • Install selenium-webdriver npm package
  • Write tests!

    Selenium and node go together great! It's easy to wrap calling jQuery through Selenium to access elements and feels natural in node!

Unit Testing JavaScript is easy 

...and it's not just about code you wrote

Linting JavaScript is easy too 

...it's like compile-time checking for JavaScript

https://github.com/jscs-dev/node-jscs

http://www.jshint.com/

Near-Instant Feedback

...because you shouldn't have to wait.

https://www.npmjs.org/package/gulp-watch

https://www.npmjs.org/package/gulp-jshint

https://www.npmjs.org/package/gulp-notify-growl

Watch files, run tasks.

Let's take it up a notch!

Sassy CSS
http://sass-lang.com/

 

Traceur Compiler
https://github.com/google/traceur-compiler

 

We can use node.js

In Development

We can use node.js for...

  • Bundling and Minification
  • Manage client dependencies
  • Aid in writing large scale JavaScript apps
    (RequireJS, WebPack, Browserify, etc.)
  • Node is fast at building things
    (Mocking, rapid prototyping)
  • Load/Performance testing
    (ie: with WebSockets, zombie + async)
  • Sassy CSS, ES6, etc.

zombie + async = load test

  • Node is fast at handling many requests
  • zombie is fast at parsing DOM without overhead
  • async, node-promise, bluebird make it easy to manage deferred code

https://github.com/calekennedy/zombie-swarm

We can use node.js

In Continuous Integration

We can use node.js for...

  • TFS and can't access build server?
    You can use Chutzpah/PhantomJS
  • MSTest can invoke tests too
  • Bamboo and others can just call gulp

TFS Unit Testing Recipe

https://www.nuget.org/packages/ExecConsoleProgram/

No Installation Needed! Tested on TFS 2012

https://www.nuget.org/packages/Chutzpah

http://qunitjs.com/

http://aspnetperformance.com/post/Unit-testing-JavaScript-as-part-of-TFS-Build.aspx

We can use node.js

In Production ...to help with client code

We can use node.js for...

  • building an SPA
  • React.js/jsx, Angular, etc

We can use node.js

In Production ...alongside legacy apps

We can use node.js for...

  • Websockets
  • JSON-based APIs
    (Wrap XML, mobile, REST)
  • Side-by-side in IIS with IISnode
    Can run as part of the same app
  • Leverage existing .NET code through edge.js
  • Scale horizontally to handle massive load

We can use node.js

...but we have a restrictive corporate policy

To get value from node, you want...

  • node.js
  • git, bower and npm
  • some packages use Ruby, Python, C/C++

..but we only use NTLM?

  • Use cntlm
  • Mirror npm internally
  • XCopy packages you need
  • npm is open source

http://cntlm.sourceforge.net/

https://www.npmjs.org/package/npm-mirror

https://www.npmjs.org/package/npm-lazy-mirror

http://www.clock.co.uk/blog/how-to-create-a-private-npmjs-repository

Questions?

Thank you!

Made with Slides.com