Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Miami node.js meetup: a hands-on introduction t...

Miami node.js meetup: a hands-on introduction to node.js

Luc Castera

June 27, 2014
Tweet

More Decks by Luc Castera

Other Decks in Programming

Transcript

  1. LUC CASTERA • Full-stack software developer & entrepreneur • Electrical

    Engineering: UVA / Georgia Tech • I work at Intellum on TribeSocial • Co-founder of job509.com & visit509.com • luccastera.com
  2. MEETUP GOALS • To build and develop a community of

    node.js experts in Miami that contribute to the global node.js ecosystem • “Learn and build together” • Example: the Seattle Ruby group
  3. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  4. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  5. V8

  6. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  7. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  8. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  9. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  10. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  11. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  12. – nodejs.org “Node.js is a platform built on Chrome's JavaScript

    runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  13. Beginner Intermediate Advanced 1. Install node.js 2. Write a program

    that prints ‘Hello Miami’ to the console 3. Write a web server that says ‘Hello Miami’ at the root URL http://localhost:3000/ 1. Write a web server that says ‘Hello Miami’ at the root URL http://localhost:3000/ 2. Use the cluster module to start a cluster of 4 servers serving the ‘Hello Miami’ app at http://localhost:3000/ 1. Use the cluster module to start a cluster of 4 servers serving the ‘Hello Miami’ app at http://localhost:3000/
  14. FAVORITE MODULES • async - avoid callback hell • underscore

    - JavaScript++ / utility belt • express - small web application framework • connect - middleware framework • mocha - testing (server-side and in browser) • grunt - task runner • sinon - test spies, stubs, and mocks • gleak - global variable leak detection • kue - priority job queue backed by redis • mongoose - mongodb ORM
  15. LESSONS LEARNED • calllback(err, data) • jshint is your friend

    (include in build process) • always use ‘return’ on callback • use streams when you should (.e.g mongoose) • move CPU intensive sections to separate process
  16. DEPLOYING NODE • Process handling: fail and restart (upstart, monit)

    • Use multiple node processes (kue) • Use a load balancer (haproxy) • upstart ulimit gotcha • stunnel for SSH • lock down npm dependencies (or shrinkwrap)
  17. WORLD CUP FEVER! • Write a program that when passed

    the name of a country, prints out the list of players currently in their national football/soccer team along with their age and current club (comma delimited) • Usage: 
 roster Chile • Output:
 Claudio Bravo, 31, Barcelona
 Eugenio Mena, 28, Santos
 Mauricio Isla, 26, Juventus • Tip: Wikipedia pages URL: 
 http://en.wikipedia.org/wiki/Chile_national_football_team#Current_squad • If you are stuck and want a hint, ask me ;-)