SlideShare a Scribd company logo
Intro to Node.JS
By Aaron Stannard
Startup Developer Evangelist, Microsoft Corporation
Examples from Today’s Talk
https://github.com/Aaronontheweb/introtonode
Meet Node
var http = require('http');
//Node function called each time a new HTTP request arrives
function onRequest(req, res){
res.writeHead(200, {'Content-Type':'text/plain'});
res.end('Hello ' + req.connection.remoteAddress + '!');
/* Write the IP addresses of our connecting client to console */
console.log('Incoming connection from ' +
req.connection.remoteAddress);
}
//Listen for connections on the port provided by the host process
var server = http.createServer(onRequest).listen(process.env.PORT);
What Is Node?
• Server Side JavaScript
• Asynchronous Web Framework
• Evented I/O Model
What Is Node?
Network I/O Libraries
+
+
=
What Makes Node Special?
• Uses the familiar JavaScript programming
model to enable server-side development
• Buries the pain of working with async /
parallel programming
• No Blocking I/O
• Can handle large concurrent loads more easily
than other technologies
• Not a silver bullet
Why Node
JavaScript is ubiquitous
Why Node
Traditional Platforms
• Things you need for
concurrent web
programming:
– Locks
– Threads / Thread Pools
– Thread Management
– Inter-Thread Communication
– Callbacks + Enclosures + Sync
to Blocking Calls
Node
• Things you need for
concurrent web
programming:
– Callbacks + Enclosures
Which looks
simpler?
Good Node Scenarios
Behavior
• High request volume, low
response-sizes
• Pub / Sub
• Real-time applications
Application
• Online games, message
passing services
• Social networks, content-
syndication services
• Chat, real-time games
Bad Node Scenarios
Behavior
• Large HTTP response sizes
• CRUD
• Transaction-heavy systems
Application
• Static file servers, reporting
tools
• Blogs, CMS
• E-Commerce
Node Concepts
• What Do Node Projects Look Like?
• Event Loop & Workers
• HTTP as a First Class Citizen
• Callbacks and Functions as Objects
• Modules & Packages
Structure of a Node Project
/projectroot/
package.json
readme.txt
web/
server.js
views/
index.html
models/
post.js
helpers/
timestamp.js
test/
route-test.js
post-test.js
node_modules/
C:[projectroot]> node web/server.js
Node server listenening on port 3000 in development mode
Tells Node and NPM what packages are required
The main entry point for your application
User-defined module for handling persistence
User-defined module for other stuff
Root of your actual application
Directory for unit tests
Output directory for all NPM installations
Event Loop + Workers
HTTP
• HTTP is a first class citizen
• Request Object
– Holds properties about the client
– Holds session state
– Passes client-data to request handlers
• Response Object
– Holds the HTTP response stream
– Can be written in chunks
Callbacks and Functions as Objects
// HTTP GET /app/list
exports.listapps = function(req, res){
var pageTitle = req.session.userName + "'s Apps";
appProvider.getAppsForUser(req.session.userName,
function(error, userApps){
if(error){
console.log(error.message);
return res.redirect('/');
}
res.render('list_apps', {locals:{title: pageTitle,
apps:userApps}})
});
}
Modules & Packages
• Including a built-in module
var http = require('http');
• Including your own module
[timestamp.js] exports.currentTime = function(){…}
[server.js] var timestamp = require(‘./helpers/timestamp');
[server.js] console.log(timestamp.currentTime());
• Node Package Manager (NPM)
[Commandline] C:> npm install express
[server.js] var express = require(‘express’);
Microsoft & Node
Microsoft wants Windows Azure to be an option
for developers regardless of stack
=>
Node on Windows Azure
• IISNode
• Windows Azure Node PowerShell Cmdlets
• Windows Azure Node SDK
• Cloud9 IDE
IISNode
• Hosts Node applications in IIS as native
modules
• Automatically manages life-cycle of node.exe
• Can load-balance multiple node.exe processes
Azure / Node Powershell Cmdlets
• Create new Azure Services
• Add Node Web and Worker Roles
• Deploy to Azure Emulator
• Import Publish Settings
• Deploy to Azure (Production / Staging)
• Source @ Github
Windows Azure SDK
• Loads Storage Settings from Web.config
• Azure Tables
• Azure Blobs
• Azure Queues
[console] C:> npm install azure
Source @ Github
Cloud9 IDE
• Browser-based IDE
• Deploys to Windows Azure
• Only way to deploy without Windows Vista / 7
Popular Node Frameworks and Tools
• Express (MVC)
• Connect
• Socket.IO
• Unit Testing:
– Assert (built-in)
– Nodeunit
Further Reference
• NodeBeginner.org - Used this to teach myself
Node when I was first getting started.
• NodeJS.org - Official Node Homepage
• Github.com/WindowsAzure – Azure bits
About Me
• Aaron Stannard
– Twitter: @Aaronontheweb
– Github: @Aaronontheweb
– Blog: http://www.aaronstannard.com/

More Related Content

PPTX
Building Web Apps with Express
PPTX
Express JS
PDF
Introduction to Node.JS Express
PDF
PPTX
Node.js Express
PPTX
Express JS
PPTX
Express js
PDF
Express node js
Building Web Apps with Express
Express JS
Introduction to Node.JS Express
Node.js Express
Express JS
Express js
Express node js

What's hot (20)

PPT
Node.js Express Framework
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PPTX
Build RESTful API Using Express JS
PDF
Nodejs first class
PPT
Node js Modules and Event Emitters
PDF
Build Web Apps using Node.js
KEY
How and why i roll my own node.js framework
KEY
Building a real life application in node js
PDF
Introduction to AngularJS For WordPress Developers
PDF
Build web application by express
ODP
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
PDF
Head First Zend Framework - Part 1 Project & Application
PDF
An Introduction to Celery
PPT
RESTful API In Node Js using Express
PDF
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
PDF
What happens in laravel 4 bootstraping
PDF
Ember.js - A JavaScript framework for creating ambitious web applications
PDF
Building web framework with Rack
PDF
Caldera Learn - LoopConf WP API + Angular FTW Workshop
PDF
Codeigniter : Two Step View - Concept Implementation
Node.js Express Framework
Workshop 4: NodeJS. Express Framework & MongoDB.
Build RESTful API Using Express JS
Nodejs first class
Node js Modules and Event Emitters
Build Web Apps using Node.js
How and why i roll my own node.js framework
Building a real life application in node js
Introduction to AngularJS For WordPress Developers
Build web application by express
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Head First Zend Framework - Part 1 Project & Application
An Introduction to Celery
RESTful API In Node Js using Express
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
What happens in laravel 4 bootstraping
Ember.js - A JavaScript framework for creating ambitious web applications
Building web framework with Rack
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Codeigniter : Two Step View - Concept Implementation
Ad

Similar to Intro to Node (20)

KEY
Node.js
KEY
Writing robust Node.js applications
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
PPT
nodejs_at_a_glance.ppt
PPT
nodejs_at_a_glance, understanding java script
PPTX
Node.js System: The Approach
PDF
Spring Web Services: SOAP vs. REST
PDF
Introduction to Node.js
PPTX
Sharding and Load Balancing in Scala - Twitter's Finagle
PPTX
Scalable network applications, event-driven - Node JS
PPT
Rapid java backend and api development for mobile devices
PDF
Node js introduction
PPTX
Node.js web-based Example :Run a local server in order to start using node.js...
PPTX
Intro to node and mongodb 1
ODP
An Overview of Node.js
PDF
soft-shake.ch - Hands on Node.js
PPTX
Node.js Workshop - Sela SDP 2015
PDF
Introduction to Node.js
PDF
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Node.js
Writing robust Node.js applications
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
nodejs_at_a_glance.ppt
nodejs_at_a_glance, understanding java script
Node.js System: The Approach
Spring Web Services: SOAP vs. REST
Introduction to Node.js
Sharding and Load Balancing in Scala - Twitter's Finagle
Scalable network applications, event-driven - Node JS
Rapid java backend and api development for mobile devices
Node js introduction
Node.js web-based Example :Run a local server in order to start using node.js...
Intro to node and mongodb 1
An Overview of Node.js
soft-shake.ch - Hands on Node.js
Node.js Workshop - Sela SDP 2015
Introduction to Node.js
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Ad

More from Aaron Stannard (8)

PPTX
How Software Developers Destroy Business Value.pptx
PPTX
The Coming OSS Sustainability Crisis
PPTX
Startup Product Development
PPTX
NoSQL Shootout: RavenDB vs MongoDB
PPTX
Location Services and Bing Maps in Windows Phone 7
PPTX
Consuming REST in .NET
PPTX
MVVM for n00bs
PPTX
How to Design Applications People Love
How Software Developers Destroy Business Value.pptx
The Coming OSS Sustainability Crisis
Startup Product Development
NoSQL Shootout: RavenDB vs MongoDB
Location Services and Bing Maps in Windows Phone 7
Consuming REST in .NET
MVVM for n00bs
How to Design Applications People Love

Recently uploaded (20)

PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
Google’s NotebookLM Unveils Video Overviews
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
creating-agentic-ai-solutions-leveraging-aws.pdf
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
PDF
DevOps & Developer Experience Summer BBQ
PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
KodekX | Application Modernization Development
PDF
Modernizing your data center with Dell and AMD
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
A Day in the Life of Location Data - Turning Where into How.pdf
Google’s NotebookLM Unveils Video Overviews
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Sensors and Actuators in IoT Systems using pdf
creating-agentic-ai-solutions-leveraging-aws.pdf
Dell Pro 14 Plus: Be better prepared for what’s coming
Belt and Road Supply Chain Finance Blockchain Solution
Enable Enterprise-Ready Security on IBM i Systems.pdf
DevOps & Developer Experience Summer BBQ
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Smarter Business Operations Powered by IoT Remote Monitoring
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
KodekX | Application Modernization Development
Modernizing your data center with Dell and AMD

Intro to Node

  • 1. Intro to Node.JS By Aaron Stannard Startup Developer Evangelist, Microsoft Corporation
  • 2. Examples from Today’s Talk https://github.com/Aaronontheweb/introtonode
  • 3. Meet Node var http = require('http'); //Node function called each time a new HTTP request arrives function onRequest(req, res){ res.writeHead(200, {'Content-Type':'text/plain'}); res.end('Hello ' + req.connection.remoteAddress + '!'); /* Write the IP addresses of our connecting client to console */ console.log('Incoming connection from ' + req.connection.remoteAddress); } //Listen for connections on the port provided by the host process var server = http.createServer(onRequest).listen(process.env.PORT);
  • 4. What Is Node? • Server Side JavaScript • Asynchronous Web Framework • Evented I/O Model
  • 5. What Is Node? Network I/O Libraries + + =
  • 6. What Makes Node Special? • Uses the familiar JavaScript programming model to enable server-side development • Buries the pain of working with async / parallel programming • No Blocking I/O • Can handle large concurrent loads more easily than other technologies • Not a silver bullet
  • 8. Why Node Traditional Platforms • Things you need for concurrent web programming: – Locks – Threads / Thread Pools – Thread Management – Inter-Thread Communication – Callbacks + Enclosures + Sync to Blocking Calls Node • Things you need for concurrent web programming: – Callbacks + Enclosures Which looks simpler?
  • 9. Good Node Scenarios Behavior • High request volume, low response-sizes • Pub / Sub • Real-time applications Application • Online games, message passing services • Social networks, content- syndication services • Chat, real-time games
  • 10. Bad Node Scenarios Behavior • Large HTTP response sizes • CRUD • Transaction-heavy systems Application • Static file servers, reporting tools • Blogs, CMS • E-Commerce
  • 11. Node Concepts • What Do Node Projects Look Like? • Event Loop & Workers • HTTP as a First Class Citizen • Callbacks and Functions as Objects • Modules & Packages
  • 12. Structure of a Node Project /projectroot/ package.json readme.txt web/ server.js views/ index.html models/ post.js helpers/ timestamp.js test/ route-test.js post-test.js node_modules/ C:[projectroot]> node web/server.js Node server listenening on port 3000 in development mode Tells Node and NPM what packages are required The main entry point for your application User-defined module for handling persistence User-defined module for other stuff Root of your actual application Directory for unit tests Output directory for all NPM installations
  • 13. Event Loop + Workers
  • 14. HTTP • HTTP is a first class citizen • Request Object – Holds properties about the client – Holds session state – Passes client-data to request handlers • Response Object – Holds the HTTP response stream – Can be written in chunks
  • 15. Callbacks and Functions as Objects // HTTP GET /app/list exports.listapps = function(req, res){ var pageTitle = req.session.userName + "'s Apps"; appProvider.getAppsForUser(req.session.userName, function(error, userApps){ if(error){ console.log(error.message); return res.redirect('/'); } res.render('list_apps', {locals:{title: pageTitle, apps:userApps}}) }); }
  • 16. Modules & Packages • Including a built-in module var http = require('http'); • Including your own module [timestamp.js] exports.currentTime = function(){…} [server.js] var timestamp = require(‘./helpers/timestamp'); [server.js] console.log(timestamp.currentTime()); • Node Package Manager (NPM) [Commandline] C:> npm install express [server.js] var express = require(‘express’);
  • 17. Microsoft & Node Microsoft wants Windows Azure to be an option for developers regardless of stack =>
  • 18. Node on Windows Azure • IISNode • Windows Azure Node PowerShell Cmdlets • Windows Azure Node SDK • Cloud9 IDE
  • 19. IISNode • Hosts Node applications in IIS as native modules • Automatically manages life-cycle of node.exe • Can load-balance multiple node.exe processes
  • 20. Azure / Node Powershell Cmdlets • Create new Azure Services • Add Node Web and Worker Roles • Deploy to Azure Emulator • Import Publish Settings • Deploy to Azure (Production / Staging) • Source @ Github
  • 21. Windows Azure SDK • Loads Storage Settings from Web.config • Azure Tables • Azure Blobs • Azure Queues [console] C:> npm install azure Source @ Github
  • 22. Cloud9 IDE • Browser-based IDE • Deploys to Windows Azure • Only way to deploy without Windows Vista / 7
  • 23. Popular Node Frameworks and Tools • Express (MVC) • Connect • Socket.IO • Unit Testing: – Assert (built-in) – Nodeunit
  • 24. Further Reference • NodeBeginner.org - Used this to teach myself Node when I was first getting started. • NodeJS.org - Official Node Homepage • Github.com/WindowsAzure – Azure bits
  • 25. About Me • Aaron Stannard – Twitter: @Aaronontheweb – Github: @Aaronontheweb – Blog: http://www.aaronstannard.com/

Editor's Notes

  • #5: Designed for Data-Intensive & Real-Time Web Applications
  • #6: Server-Side (!!) JavaScript Built on top of the Chrome V8 Engine Designed for data-intensive & real-time web applications Everything is asynchronous
  • #8: Scenarios: Large request volume, low response size Multiplayer games Social / real-time applications Pub/Sub Uses a language universal to all web developers Allows developers with no prior back-end experience to leverage their skills for real applications
  • #16: Callbacks and the Programming Model Closures Functions as Objects Design Patterns
  • #23: HTML5-based IDE Free to use $12/mo for private projects Deploys to Windows Azure Hides ~90% of the configuration stuff