SlideShare ist ein Scribd-Unternehmen logo
1 von 25
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/

Weitere ähnliche Inhalte

Was ist angesagt?

Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JSCakra Danu Sedayu
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first classFin Chen
 
Node js Modules and Event Emitters
Node js Modules and Event EmittersNode js Modules and Event Emitters
Node js Modules and Event EmittersTheCreativedev Blog
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.jsdavidchubbs
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node jsfakedarren
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersCaldera Labs
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by expressShawn Meng
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationJace Ju
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to CeleryIdan Gazit
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Caldera Labs
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCalderaLearn
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 

Was ist angesagt? (20)

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

Ähnlich wie Intro to Node.JS: Server-Side JavaScript and Event-Driven Programming

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
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...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...Tom Croucher
 
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...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...Tom Croucher
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Node.js System: The Approach
Node.js System: The ApproachNode.js System: The Approach
Node.js System: The ApproachHaci Murat Yaman
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRichard Lee
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleGeoff Ballinger
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSCosmin Mereuta
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.jsAyush Mishra
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015Nir Noy
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js PlatformNaresh Chintalcheru
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 

Ähnlich wie Intro to Node.JS: Server-Side JavaScript and Event-Driven Programming (20)

Node.js
Node.jsNode.js
Node.js
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
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...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...
 
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...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.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Node.js System: The Approach
Node.js System: The ApproachNode.js System: The Approach
Node.js System: The Approach
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's Finagle
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 

Mehr von Aaron Stannard

The Coming OSS Sustainability Crisis
The Coming OSS Sustainability CrisisThe Coming OSS Sustainability Crisis
The Coming OSS Sustainability CrisisAaron Stannard
 
Startup Product Development
Startup Product DevelopmentStartup Product Development
Startup Product DevelopmentAaron Stannard
 
NoSQL Shootout: RavenDB vs MongoDB
NoSQL Shootout: RavenDB vs MongoDBNoSQL Shootout: RavenDB vs MongoDB
NoSQL Shootout: RavenDB vs MongoDBAaron Stannard
 
Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Aaron Stannard
 
Consuming REST in .NET
Consuming REST in .NETConsuming REST in .NET
Consuming REST in .NETAaron Stannard
 
How to Design Applications People Love
How to Design Applications People LoveHow to Design Applications People Love
How to Design Applications People LoveAaron Stannard
 

Mehr von Aaron Stannard (7)

The Coming OSS Sustainability Crisis
The Coming OSS Sustainability CrisisThe Coming OSS Sustainability Crisis
The Coming OSS Sustainability Crisis
 
Startup Product Development
Startup Product DevelopmentStartup Product Development
Startup Product Development
 
NoSQL Shootout: RavenDB vs MongoDB
NoSQL Shootout: RavenDB vs MongoDBNoSQL Shootout: RavenDB vs MongoDB
NoSQL Shootout: RavenDB vs MongoDB
 
Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7
 
Consuming REST in .NET
Consuming REST in .NETConsuming REST in .NET
Consuming REST in .NET
 
MVVM for n00bs
MVVM for n00bsMVVM for n00bs
MVVM for n00bs
 
How to Design Applications People Love
How to Design Applications People LoveHow to Design Applications People Love
How to Design Applications People Love
 

Kürzlich hochgeladen

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Kürzlich hochgeladen (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Intro to Node.JS: Server-Side JavaScript and Event-Driven Programming

  • 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/

Hinweis der Redaktion

  1. Designed for Data-Intensive & Real-Time Web Applications
  2. Server-Side (!!) JavaScript Built on top of the Chrome V8 Engine Designed for data-intensive & real-time web applications Everything is asynchronous
  3. 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
  4. Callbacks and the Programming Model Closures Functions as Objects Design Patterns
  5. HTML5-based IDE Free to use $12/mo for private projects Deploys to Windows Azure Hides ~90% of the configuration stuff