SlideShare a Scribd company logo
Developing for Node.js
@debug_mode

Dhananjay Kumar
Agenda









What is this buzz Node
Create first HTTP Server : Demo
How Node works ?
Understanding EventLoop and Callback
Create Echo Server : Demo
Create app to upload large file asynchronously : Demo
Create routers using Crossroads : Demo
Create REST API using Express and Visual Studio : Demo
Your Presenter
 Dhananjay Kumar
– Evangelist , Telerik
– Microsoft MVP
– Mentror C-Sharpcorner
– @debug_mode
– http://debugmode.net
– http://telerikhelper.net
– Dhananjay.kumar@telerik.com
What is Node.js ?

Asynchronous Event Driven Server
Side JavaScript
Runs on Google JS V8 Engine
Non-blocking I/O and File API

Highly Scalable

Single Threaded
Node Apps are created using JavaScript
Faster in performance
Demo : Create first web Server
Let us understand code line by line
Line 1

Line 4

•
•

•
•

•

Loading http module
It is required to work with HTTP
request and response
It is required to create HTTP Server

Line 2
•
•

•
•

Create server using createServer()
function
It takes a callback as parameter . It
takes HTTP request and response
as paramtere
Callback got two input parameter .
Both input parameters are
readable and writeable stream

•

Writing response header
It takes a JSON object as optional
second parameter
second parameter contains
informations like

•
•
•
•

Content Length
Content Type
Connection
Accept Type
Let us understand code line by line
Line 9

Line 5-6
•
•
•

Writing data in response
Data can be written in form of
string or buffer
ServerResponse.end indicates the
communication has been finished

•

•

•

Line 10
•

Printing a message

createServer() method
is finished with chained
http.Server.listen()
method
It specifies port number
on which request will be
listen
Optional host name
How Node works ?
• It works on single thread
• It handles all request asynchronously
on same thread
• It does not create new thread for each
request which is very unlikely like
other web servers
• It does not wait to complete a request

Keep poling for event in
EventLoop

When gets event process
asynchronously and
assign a CallBack

CallBack get executed
once event execution is
complete
Visual Studio and Node

Manage NPM Modules
Events in Node
• Each objects in Node emit an asynchronous
event.
• event is handled by an object EventEmitter.
• EventEmitter is underneath every object.
Streams in Node
Demo on echo server

Demo on uploading file
asynchronously
Routers in Node
Modules to create Routers
Demo add routes using Crossroads

•
•
•
•
•

Express
Director
Bouncy
Backbone
Crossroads
Demo : REST API on Node.js
•
•
•
•
•

Export data from a Module
Add routes in Express
Map routes to function
Test in fiddler
Use Visual Studio Template
Demo : REST API on Node.js
Step 1 : Create JSON Object Array
Demo : REST API on Node.js
Step 2 : Retrieve function
Demo : REST API on Node.js
Step 3 : Add function
Demo : REST API on Node.js
Step 4 : Update function
Demo : REST API on Node.js
Step 5 : Delete function
Demo : REST API on Node.js
Step 5 : Add Routes
Thanks & Questions?
@debug_mode

More Related Content

PDF
Introduction to React Native
dvcrn
 
PPTX
Nodejsvs
Dhananjay Kumar
 
PDF
Intro To React Native
FITC
 
PDF
Introduction to react native
Dani Akash
 
PPTX
Say Hello to React day2 presentation
Smile Gupta
 
PDF
Angular 2 overview
Jesse Warden
 
PDF
Angular2 intro
Shawn McKay
 
PDF
Angular 2 - Core Concepts
Fabio Biondi
 
Introduction to React Native
dvcrn
 
Nodejsvs
Dhananjay Kumar
 
Intro To React Native
FITC
 
Introduction to react native
Dani Akash
 
Say Hello to React day2 presentation
Smile Gupta
 
Angular 2 overview
Jesse Warden
 
Angular2 intro
Shawn McKay
 
Angular 2 - Core Concepts
Fabio Biondi
 

What's hot (20)

PDF
Type script for_java_dev_jul_2020
Yakov Fain
 
PPTX
Talk for DevFest 2021 - GDG Bénin
Ezéchiel Amen AGBLA
 
PDF
Angular 2... so can I use it now??
Laurent Duveau
 
ODP
Docker - An Introduction
Knoldus Inc.
 
PPTX
Angular1x and Angular 2 for Beginners
Oswald Campesato
 
ODP
Introduction to Angular 2
Knoldus Inc.
 
PPTX
Fullstack workshop
Assaf Gannon
 
PDF
Building blocks of Angular
Knoldus Inc.
 
PDF
Angular 2 Essential Training
Patrick Schroeder
 
PDF
An Intro to Angular 2
Ron Heft
 
PPTX
Angular 2 Migration - JHipster Meetup 6
William Marques
 
PDF
Angular2 with type script
Ravi Mone
 
PDF
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Johannes Weber
 
PDF
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
DOCX
Protractor end-to-end testing framework for angular js
codeandyou forums
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PDF
Angular 2: What's New?
jbandi
 
PPTX
Back to the ng2 Future
Jeremy Likness
 
PDF
Алексей Волков "Введение в React Native"
Fwdays
 
PPTX
AngularJS: Service, factory & provider
Corley S.r.l.
 
Type script for_java_dev_jul_2020
Yakov Fain
 
Talk for DevFest 2021 - GDG Bénin
Ezéchiel Amen AGBLA
 
Angular 2... so can I use it now??
Laurent Duveau
 
Docker - An Introduction
Knoldus Inc.
 
Angular1x and Angular 2 for Beginners
Oswald Campesato
 
Introduction to Angular 2
Knoldus Inc.
 
Fullstack workshop
Assaf Gannon
 
Building blocks of Angular
Knoldus Inc.
 
Angular 2 Essential Training
Patrick Schroeder
 
An Intro to Angular 2
Ron Heft
 
Angular 2 Migration - JHipster Meetup 6
William Marques
 
Angular2 with type script
Ravi Mone
 
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Johannes Weber
 
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
Protractor end-to-end testing framework for angular js
codeandyou forums
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
Angular 2: What's New?
jbandi
 
Back to the ng2 Future
Jeremy Likness
 
Алексей Волков "Введение в React Native"
Fwdays
 
AngularJS: Service, factory & provider
Corley S.r.l.
 
Ad

Similar to Node.js (20)

PDF
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
PPT
Node.js
Pravin Mishra
 
PPTX
Node.js Workshop - Sela SDP 2015
Nir Noy
 
PPTX
Intro to Node
Aaron Stannard
 
PPTX
A slightly advanced introduction to node.js
Sudar Muthu
 
ODP
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
PPTX
Nodejs
Vinod Kumar Marupu
 
PDF
FITC - Node.js 101
Rami Sayar
 
PPT
Node js beginner
Sureshreddy Nalimela
 
PPTX
Introduction to node
girish82
 
PDF
Node.js 101 with Rami Sayar
FITC
 
PPTX
Intsllation & 1st program nodejs
monikadeshmane
 
PDF
Basic Understanding and Implement of Node.js
Gary Yeh
 
PDF
Day In A Life Of A Node.js Developer
Edureka!
 
PDF
Day in a life of a node.js developer
Edureka!
 
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
PDF
NodeJS
Predhin Sapru
 
PPTX
NodeJS guide for beginners
Enoch Joshua
 
PPTX
Unit 1 Express J for mean stack and mern
Rahul Borate
 
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
Node.js
Pravin Mishra
 
Node.js Workshop - Sela SDP 2015
Nir Noy
 
Intro to Node
Aaron Stannard
 
A slightly advanced introduction to node.js
Sudar Muthu
 
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
FITC - Node.js 101
Rami Sayar
 
Node js beginner
Sureshreddy Nalimela
 
Introduction to node
girish82
 
Node.js 101 with Rami Sayar
FITC
 
Intsllation & 1st program nodejs
monikadeshmane
 
Basic Understanding and Implement of Node.js
Gary Yeh
 
Day In A Life Of A Node.js Developer
Edureka!
 
Day in a life of a node.js developer
Edureka!
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
NodeJS guide for beginners
Enoch Joshua
 
Unit 1 Express J for mean stack and mern
Rahul Borate
 
Ad

More from Dhananjay Kumar (20)

PPTX
Slides of webinar Kendo UI and Knockout.js
Dhananjay Kumar
 
PPTX
No SQL with Kendo UI
Dhananjay Kumar
 
PPTX
Patterns in JavaScript
Dhananjay Kumar
 
PPTX
Presenter deck icenium hol
Dhananjay Kumar
 
PPTX
Bringbestoinyou
Dhananjay Kumar
 
PPTX
Java script
Dhananjay Kumar
 
PPTX
Windows azure mobile service
Dhananjay Kumar
 
PPTX
Test studiowebinaraugcodedstep
Dhananjay Kumar
 
PPTX
Functions and Objects in JavaScript
Dhananjay Kumar
 
PPTX
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Dhananjay Kumar
 
PPTX
Cloud Based Enterprise Apps using Everlive
Dhananjay Kumar
 
PPTX
A Look into Automated Web UI Test
Dhananjay Kumar
 
PPTX
Windows phone 8 app using Kendo UI
Dhananjay Kumar
 
PPTX
Cross platformmobileapp
Dhananjay Kumar
 
PPTX
Windows aazuremobileservices
Dhananjay Kumar
 
PPTX
Rad controlforwindows25thapril
Dhananjay Kumar
 
PPTX
Data asservice
Dhananjay Kumar
 
PPTX
WCF for begineers
Dhananjay Kumar
 
PPTX
Windows storemindcrcaker23rdmarch
Dhananjay Kumar
 
PPTX
Test studio webinar march 2013
Dhananjay Kumar
 
Slides of webinar Kendo UI and Knockout.js
Dhananjay Kumar
 
No SQL with Kendo UI
Dhananjay Kumar
 
Patterns in JavaScript
Dhananjay Kumar
 
Presenter deck icenium hol
Dhananjay Kumar
 
Bringbestoinyou
Dhananjay Kumar
 
Java script
Dhananjay Kumar
 
Windows azure mobile service
Dhananjay Kumar
 
Test studiowebinaraugcodedstep
Dhananjay Kumar
 
Functions and Objects in JavaScript
Dhananjay Kumar
 
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Dhananjay Kumar
 
Cloud Based Enterprise Apps using Everlive
Dhananjay Kumar
 
A Look into Automated Web UI Test
Dhananjay Kumar
 
Windows phone 8 app using Kendo UI
Dhananjay Kumar
 
Cross platformmobileapp
Dhananjay Kumar
 
Windows aazuremobileservices
Dhananjay Kumar
 
Rad controlforwindows25thapril
Dhananjay Kumar
 
Data asservice
Dhananjay Kumar
 
WCF for begineers
Dhananjay Kumar
 
Windows storemindcrcaker23rdmarch
Dhananjay Kumar
 
Test studio webinar march 2013
Dhananjay Kumar
 

Recently uploaded (20)

PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 

Node.js

  • 2. Agenda         What is this buzz Node Create first HTTP Server : Demo How Node works ? Understanding EventLoop and Callback Create Echo Server : Demo Create app to upload large file asynchronously : Demo Create routers using Crossroads : Demo Create REST API using Express and Visual Studio : Demo
  • 3. Your Presenter  Dhananjay Kumar – Evangelist , Telerik – Microsoft MVP – Mentror C-Sharpcorner – @debug_mode – http://debugmode.net – http://telerikhelper.net – [email protected]
  • 4. What is Node.js ? Asynchronous Event Driven Server Side JavaScript Runs on Google JS V8 Engine Non-blocking I/O and File API Highly Scalable Single Threaded Node Apps are created using JavaScript Faster in performance
  • 5. Demo : Create first web Server
  • 6. Let us understand code line by line Line 1 Line 4 • • • • • Loading http module It is required to work with HTTP request and response It is required to create HTTP Server Line 2 • • • • Create server using createServer() function It takes a callback as parameter . It takes HTTP request and response as paramtere Callback got two input parameter . Both input parameters are readable and writeable stream • Writing response header It takes a JSON object as optional second parameter second parameter contains informations like • • • • Content Length Content Type Connection Accept Type
  • 7. Let us understand code line by line Line 9 Line 5-6 • • • Writing data in response Data can be written in form of string or buffer ServerResponse.end indicates the communication has been finished • • • Line 10 • Printing a message createServer() method is finished with chained http.Server.listen() method It specifies port number on which request will be listen Optional host name
  • 8. How Node works ? • It works on single thread • It handles all request asynchronously on same thread • It does not create new thread for each request which is very unlikely like other web servers • It does not wait to complete a request Keep poling for event in EventLoop When gets event process asynchronously and assign a CallBack CallBack get executed once event execution is complete
  • 9. Visual Studio and Node Manage NPM Modules
  • 10. Events in Node • Each objects in Node emit an asynchronous event. • event is handled by an object EventEmitter. • EventEmitter is underneath every object.
  • 11. Streams in Node Demo on echo server Demo on uploading file asynchronously
  • 12. Routers in Node Modules to create Routers Demo add routes using Crossroads • • • • • Express Director Bouncy Backbone Crossroads
  • 13. Demo : REST API on Node.js • • • • • Export data from a Module Add routes in Express Map routes to function Test in fiddler Use Visual Studio Template
  • 14. Demo : REST API on Node.js Step 1 : Create JSON Object Array
  • 15. Demo : REST API on Node.js Step 2 : Retrieve function
  • 16. Demo : REST API on Node.js Step 3 : Add function
  • 17. Demo : REST API on Node.js Step 4 : Update function
  • 18. Demo : REST API on Node.js Step 5 : Delete function
  • 19. Demo : REST API on Node.js Step 5 : Add Routes

Editor's Notes

  • #10: https://nodejstools.codeplex.com/releases/view/114437 : download from here
  • #11: https://nodejstools.codeplex.com/releases/view/114437 : download from here