SlideShare a Scribd company logo
www.edureka.co/mastering-node-js
View Mastering Node.js course details at www.edureka.co/mastering-node-js
Day In A Life Of A Node.js Developer
For Queries:
Post on Twitter @edurekaIN: #askEdureka
Post on Facebook /edurekaIN
For more details please contact us:
US : 1800 275 9730 (toll free)
INDIA : +91 88808 62004
Email Us : sales@edureka.co
Slide 2 www.edureka.co/mastering-node-js
Objectives
At the end of the session you will be able to:
๏‚ฎUnderstand basics of Node.js Development
๏‚ฎUse Node's Package Manager
๏‚ฎDevelop Server Side Applications
๏‚ฎCreate Restful APIs
๏‚ฎTest and Debug Code
Slide 3 www.edureka.co/mastering-node-jsSlide 3
What is Node.js ?
๏‚ฎNode.js is an open source, cross-platform runtime environment for server-side and networking applications
๏‚ฎNode.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft
Windows, Linux, FreeBSD, NonStop and IBM. -- Wikipedia
๏‚ฎThis is based on Googleโ€™s V8 JavaScript Engine
Slide 4 www.edureka.co/mastering-node-jsSlide 4
What is Node.js ? (Contd.)
Guess What ?
ยป ITโ€™s SINGLE THREADED !!
ยป No worries about : race conditions, deadlocks and other problems that go with multi-threading.
ยป โ€œAlmost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks,
less-than-expert programmers are able to develop scalable systems.โ€ - (courtesy : nodejs.org)
Event
Loop
Event
Queue
Thread Pool
file system
network
process
other
Slide 5 www.edureka.co/mastering-node-jsSlide 5
Use-Cases of Node.js
1. Walmart executives believe that the benefit of using Node.js was
far greater than any risk in adopting a new technology
2. They re-engineered their mobile app to run on Node.js where all
the front end code gets executed on back-end
3. โ€œWe rely on services all over the world,โ€ says Almaer (V.P Mobile
Architecture) โ€œWe do not control all of those services. Node
allows us to front all these servicesโ€ฆ and scale up very nicely.
Itโ€™s perfect for what weโ€™re doing in mobile.โ€
Server Side Web Applications
1. Server Side Web Applications
Advantages
Slide 6 www.edureka.co/mastering-node-jsSlide 6
Use-Cases of Node.js (Contd.)
1. Linkedin is also leaning heavily on Node.js (Linkedin mobile and
tablet app is 95% html/web based)
2. โ€œWeโ€™re still full-on Node. We are excited that it can scale,โ€ says
Kiran Prasad (Head of Linkedinโ€™s Mobile Development Team).
โ€œOver the past few months, weโ€™ve made performance tweaks so
we can scale even more. On four boxes, we can now handle 20
times the load we were handling before.โ€
Highly Scalable
1. Server Side Web Applications
2. Highly Scalable
Advantages
Slide 7 www.edureka.co/mastering-node-jsSlide 7
Use-Cases of Node.js (Contd.)
1. When he first built Voxer, Matt Ranney (Voxerโ€™s CTO) ran a test
to see how many connections he could open on a single server.
"I just decided to open as many connections as I could, just to
see where things would fall down," Ranney says
2. "With Node, I could open, well, all of them. I couldn't open any
more connections without getting more IP addresses on my test
machine. Node uses such small amounts of memory, it's
astounding. I ran out of port numbers."
Low Memory Consumption
1. Server Side Web Applications
2. Highly Scalable
3. Low Memory Consumption
Advantages
Slide 8 www.edureka.co/mastering-node-jsSlide 8
Basics of Node.js : npm
๏‚ฎnpm used to stand for Node Package Manager. However it is not an acronym anymore. npm is not a Node.js
specific tool
๏‚ฎnpm is a registry of reusable modules and packages written by various developers
ยป Yes, you can publish your own npm packages
๏‚ฎThere are two ways to install npm packages :
ยป Locally : To use and depend on the package from your own module or project
ยป Globally: To use across the system, like a command line tool
Slide 9 www.edureka.co/mastering-node-jsSlide 9
1. eBay launched ql.io, a gateway for HTTP APIs, using Node.js as
the runtime stack. eBay was able to tune a regular quality
Ubuntu workstation to handle more than 120,000 active
connections per Node.js process with each connection
consuming about 2K of memory.
Advantages
Use-Cases of Node.js (Contd.)
1. Server Side Web Applications
2. Highly Scalable
3. Low Memory Consumption
4. Increase engineering clock
speed
5. Improve end user experience
Increase engineering clock speed
Improve end user experience
Slide 10 www.edureka.co/mastering-node-jsSlide 10
Node.js Developers Create Sever Side Application
Slide 11Slide 11Slide 11 www.edureka.co/mastering-node-js
๏‚ฎ To run the server, copy the code in any folder and run on the command line: node example.js
ยป As you can see above, โ€œhttpโ€ is a built-in module that is shipped with node.js
var http = require('http');
http.createServer(function (req, res)
{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Basics of Node.js: A Simple Web Server
Slide 12 www.edureka.co/mastering-node-jsSlide 12Slide 12Slide 12
Two Way Communication : Socket.io
๏‚ฎ Socket.io is a fast, real-time engine. It is an npm package.
๏‚ฎ Transmitting messages and Receiving message between client and server is simple: Events.
๏‚ฎ On server/client when sending a message use socket.emit(โ€˜eventnameโ€™,data). โ€œeventnameโ€ can be any string
๏‚ฎ And data can be any data: even Binary data!
๏‚ฎ On server/client when you want to listen to events-messages use socket.on(โ€˜eventnameโ€™,callbackFunction).
๏‚ฎ Where the callbackFunction is a function that accepts a Data argument : Data sent by the other party.
Slide 13 www.edureka.co/mastering-node-jsSlide 13Slide 13Slide 13
๏‚ฎ A simple example:
//Server-side
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(80);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
//client-side
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
Creating Simple Chat Application
Slide 14 www.edureka.co/mastering-node-jsSlide 14Slide 14Slide 14
๏‚ฎ Besides โ€˜connectโ€™, โ€˜messageโ€™ and โ€˜disconnectโ€™ you can use any custom event names
๏‚ฎ You could also have a separation of concerns by namespacing. Namespacing also means, that the same
websocket connection is used but is multiplexed
var io = require('socket.io').listen(80);
var chat = io
.of('/chat')
.on('connection', function (socket) {
socket.emit('a message', {
that: 'only'
, '/chat': 'will get'
}); });
var news = io
.of('/news')
.on('connection', function (socket) {
socket.emit('item', { news: 'item' });
});
<script>
var chat = io.connect('http://localhost/chat')
, news = io.connect('http://localhost/news');
chat.on('connect', function () {
chat.emit('hi!');
});
news.on('news', function () {
news.emit('woot');
});
</script>
Creating Simple Chat Application
Slide 15 www.edureka.co/mastering-node-jsSlide 15
Node.js Developers Use RESTful API With Node.js
Slide 16 www.edureka.co/mastering-node-jsSlide 16Slide 16Slide 16
RESTful API With Node.js
๏‚ฎ REST stands for Representational State Transfer. It is an architecture that allows client-server communication
through a uniform interface.
๏‚ฎ We will create a Restful Web Service with Node.js to perform CRUD operations ( create, read, update, delete )
๏‚ฎ By convention, HTTP verbs, such as GET, POST, PUT, and DELETE are mapped to retrieving, creating,
updating, and removing the resources specified by the URL
Slide 17 www.edureka.co/mastering-node-js
DEMO
Slide 18 www.edureka.co/mastering-node-jsSlide 18
Node.js Developers Have To Debug
and Test the Codes
Slide 19 www.edureka.co/mastering-node-jsSlide 19Slide 19Slide 19
๏‚ฎ Node.js has a built in command line debugger. The debugger is invoked by starting your application using the
debug keyword, like below :
โ€ข node debug server.js
var http = require('http');
http.createServer(function (req, res)
{
debugger;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Debugging in Node.js
๏‚ฎ Breakpoints are used to stop the execution and examine the application.
๏‚ฎ One way to add a breakpoint is by adding a line to your application where you want to put the breakpoint. This
line should contain the statement debugger;
Slide 20 www.edureka.co/mastering-node-jsSlide 20Slide 20Slide 20
TDD Flavor BDD Flavor
Unit Testing
๏‚ฎ Test-driven development (TDD) is a
software development process that
relies on the repetition of a very
short development cycle
๏‚ฎ BDD (Behaviour Driven Development) is
a synthesis and refinement of practices
stemming from TDD (Test Driven
Development) and ATDD (Acceptance
Test Driven Development)
Testing in Node.js
๏‚ฎ Unit testing is a type of automated testing where you write logic to test discrete parts of your application.
Slide 21 www.edureka.co/mastering-node-jsSlide 21Slide 21Slide 21
Mocha is a feature-rich JavaScript test framework running on node.js and the browser,
making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible
and accurate reporting, while mapping uncaught exceptions to the correct test cases
Jasmine is a behavior-driven development framework for testing JavaScript code. It
does not depend on any other JavaScript frameworks. It does not require a DOM.
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully
paired with any JavaScript testing framework
Testing in Node.js
Slide 22 www.edureka.co/mastering-node-js
Questions
Slide 23 www.edureka.co/mastering-node-js
Ad

More Related Content

What's hot (20)

Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4
Oliver Wahlen
ย 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
Katy Slemon
ย 
Clojure Web Development
Clojure Web DevelopmentClojure Web Development
Clojure Web Development
Hong Jiang
ย 
Mahesh_Dimble
Mahesh_DimbleMahesh_Dimble
Mahesh_Dimble
Mahesh Dimble
ย 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
Matt Raible
ย 
MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014
ivanjokerbr
ย 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Matt Raible
ย 
Midas - on-the-fly schema migration tool for MongoDB.
Midas - on-the-fly schema migration tool for MongoDB.Midas - on-the-fly schema migration tool for MongoDB.
Midas - on-the-fly schema migration tool for MongoDB.
Dhaval Dalal
ย 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
ย 
The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid Applications
Haim Michael
ย 
Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019
Matt Raible
ย 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Carlo Bonamico
ย 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
Carlo Bonamico
ย 
Introduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and SilverlightIntroduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and Silverlight
Peter Gfader
ย 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
oscon2007
ย 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Edureka!
ย 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
ย 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
Hazem Saleh
ย 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
ย 
Seven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuseSeven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuse
Matt Raible
ย 
Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4
Oliver Wahlen
ย 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
Katy Slemon
ย 
Clojure Web Development
Clojure Web DevelopmentClojure Web Development
Clojure Web Development
Hong Jiang
ย 
Mahesh_Dimble
Mahesh_DimbleMahesh_Dimble
Mahesh_Dimble
Mahesh Dimble
ย 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
Matt Raible
ย 
MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014MiTM Attacks in Android Apps - TDC 2014
MiTM Attacks in Android Apps - TDC 2014
ivanjokerbr
ย 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Matt Raible
ย 
Midas - on-the-fly schema migration tool for MongoDB.
Midas - on-the-fly schema migration tool for MongoDB.Midas - on-the-fly schema migration tool for MongoDB.
Midas - on-the-fly schema migration tool for MongoDB.
Dhaval Dalal
ย 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
ย 
The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid Applications
Haim Michael
ย 
Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019
Matt Raible
ย 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Carlo Bonamico
ย 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
Carlo Bonamico
ย 
Introduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and SilverlightIntroduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and Silverlight
Peter Gfader
ย 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
oscon2007
ย 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Edureka!
ย 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
ย 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
Hazem Saleh
ย 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
ย 
Seven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuseSeven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuse
Matt Raible
ย 

Similar to Day In A Life Of A Node.js Developer (20)

NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
Edureka!
ย 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
ย 
Node js
Node jsNode js
Node js
Chirag Parmar
ย 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
ย 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
Nir Noy
ย 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
Nicholas Jansma
ย 
Node JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHatNode JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHat
Scholarhat
ย 
unit 2 of Full stack web development subject
unit 2 of Full stack web development subjectunit 2 of Full stack web development subject
unit 2 of Full stack web development subject
JeneferAlan1
ย 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
Collaboration Technologies
ย 
Proposal
ProposalProposal
Proposal
Constantine Priemski
ย 
Nodejs
NodejsNodejs
Nodejs
dssprakash
ย 
Nodejs
NodejsNodejs
Nodejs
Vinod Kumar Marupu
ย 
Basic API Creation with Node.JS
Basic API Creation with Node.JSBasic API Creation with Node.JS
Basic API Creation with Node.JS
Azilen Technologies Pvt. Ltd.
ย 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
ย 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdf
iDataScientists
ย 
node.js interview questions and answers.
node.js interview questions and answers.node.js interview questions and answers.
node.js interview questions and answers.
JyothiAmpally
ย 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
PSK Technolgies Pvt. Ltd. IT Company Nagpur
ย 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
PSK Technolgies Pvt. Ltd. IT Company Nagpur
ย 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
sanskriti agarwal
ย 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdf
Abanti Aazmin
ย 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
Edureka!
ย 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
ย 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
ย 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
Nir Noy
ย 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
Nicholas Jansma
ย 
Node JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHatNode JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHat
Scholarhat
ย 
unit 2 of Full stack web development subject
unit 2 of Full stack web development subjectunit 2 of Full stack web development subject
unit 2 of Full stack web development subject
JeneferAlan1
ย 
Nodejs
NodejsNodejs
Nodejs
dssprakash
ย 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
ย 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdf
iDataScientists
ย 
node.js interview questions and answers.
node.js interview questions and answers.node.js interview questions and answers.
node.js interview questions and answers.
JyothiAmpally
ย 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
sanskriti agarwal
ย 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdf
Abanti Aazmin
ย 
Ad

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
ย 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
ย 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
ย 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
ย 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
ย 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
ย 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
ย 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
ย 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
ย 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
ย 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
ย 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
ย 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
ย 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
ย 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
ย 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
ย 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
ย 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
ย 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
ย 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
ย 
What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
ย 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
ย 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
ย 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
ย 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
ย 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
ย 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
ย 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
ย 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
ย 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
ย 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
ย 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
ย 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
ย 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
ย 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
ย 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
ย 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
ย 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
ย 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
ย 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
ย 
Ad

Recently uploaded (20)

Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
ย 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
ย 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 

Day In A Life Of A Node.js Developer

  • 1. www.edureka.co/mastering-node-js View Mastering Node.js course details at www.edureka.co/mastering-node-js Day In A Life Of A Node.js Developer For Queries: Post on Twitter @edurekaIN: #askEdureka Post on Facebook /edurekaIN For more details please contact us: US : 1800 275 9730 (toll free) INDIA : +91 88808 62004 Email Us : [email protected]
  • 2. Slide 2 www.edureka.co/mastering-node-js Objectives At the end of the session you will be able to: ๏‚ฎUnderstand basics of Node.js Development ๏‚ฎUse Node's Package Manager ๏‚ฎDevelop Server Side Applications ๏‚ฎCreate Restful APIs ๏‚ฎTest and Debug Code
  • 3. Slide 3 www.edureka.co/mastering-node-jsSlide 3 What is Node.js ? ๏‚ฎNode.js is an open source, cross-platform runtime environment for server-side and networking applications ๏‚ฎNode.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, Linux, FreeBSD, NonStop and IBM. -- Wikipedia ๏‚ฎThis is based on Googleโ€™s V8 JavaScript Engine
  • 4. Slide 4 www.edureka.co/mastering-node-jsSlide 4 What is Node.js ? (Contd.) Guess What ? ยป ITโ€™s SINGLE THREADED !! ยป No worries about : race conditions, deadlocks and other problems that go with multi-threading. ยป โ€œAlmost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop scalable systems.โ€ - (courtesy : nodejs.org) Event Loop Event Queue Thread Pool file system network process other
  • 5. Slide 5 www.edureka.co/mastering-node-jsSlide 5 Use-Cases of Node.js 1. Walmart executives believe that the benefit of using Node.js was far greater than any risk in adopting a new technology 2. They re-engineered their mobile app to run on Node.js where all the front end code gets executed on back-end 3. โ€œWe rely on services all over the world,โ€ says Almaer (V.P Mobile Architecture) โ€œWe do not control all of those services. Node allows us to front all these servicesโ€ฆ and scale up very nicely. Itโ€™s perfect for what weโ€™re doing in mobile.โ€ Server Side Web Applications 1. Server Side Web Applications Advantages
  • 6. Slide 6 www.edureka.co/mastering-node-jsSlide 6 Use-Cases of Node.js (Contd.) 1. Linkedin is also leaning heavily on Node.js (Linkedin mobile and tablet app is 95% html/web based) 2. โ€œWeโ€™re still full-on Node. We are excited that it can scale,โ€ says Kiran Prasad (Head of Linkedinโ€™s Mobile Development Team). โ€œOver the past few months, weโ€™ve made performance tweaks so we can scale even more. On four boxes, we can now handle 20 times the load we were handling before.โ€ Highly Scalable 1. Server Side Web Applications 2. Highly Scalable Advantages
  • 7. Slide 7 www.edureka.co/mastering-node-jsSlide 7 Use-Cases of Node.js (Contd.) 1. When he first built Voxer, Matt Ranney (Voxerโ€™s CTO) ran a test to see how many connections he could open on a single server. "I just decided to open as many connections as I could, just to see where things would fall down," Ranney says 2. "With Node, I could open, well, all of them. I couldn't open any more connections without getting more IP addresses on my test machine. Node uses such small amounts of memory, it's astounding. I ran out of port numbers." Low Memory Consumption 1. Server Side Web Applications 2. Highly Scalable 3. Low Memory Consumption Advantages
  • 8. Slide 8 www.edureka.co/mastering-node-jsSlide 8 Basics of Node.js : npm ๏‚ฎnpm used to stand for Node Package Manager. However it is not an acronym anymore. npm is not a Node.js specific tool ๏‚ฎnpm is a registry of reusable modules and packages written by various developers ยป Yes, you can publish your own npm packages ๏‚ฎThere are two ways to install npm packages : ยป Locally : To use and depend on the package from your own module or project ยป Globally: To use across the system, like a command line tool
  • 9. Slide 9 www.edureka.co/mastering-node-jsSlide 9 1. eBay launched ql.io, a gateway for HTTP APIs, using Node.js as the runtime stack. eBay was able to tune a regular quality Ubuntu workstation to handle more than 120,000 active connections per Node.js process with each connection consuming about 2K of memory. Advantages Use-Cases of Node.js (Contd.) 1. Server Side Web Applications 2. Highly Scalable 3. Low Memory Consumption 4. Increase engineering clock speed 5. Improve end user experience Increase engineering clock speed Improve end user experience
  • 10. Slide 10 www.edureka.co/mastering-node-jsSlide 10 Node.js Developers Create Sever Side Application
  • 11. Slide 11Slide 11Slide 11 www.edureka.co/mastering-node-js ๏‚ฎ To run the server, copy the code in any folder and run on the command line: node example.js ยป As you can see above, โ€œhttpโ€ is a built-in module that is shipped with node.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); Basics of Node.js: A Simple Web Server
  • 12. Slide 12 www.edureka.co/mastering-node-jsSlide 12Slide 12Slide 12 Two Way Communication : Socket.io ๏‚ฎ Socket.io is a fast, real-time engine. It is an npm package. ๏‚ฎ Transmitting messages and Receiving message between client and server is simple: Events. ๏‚ฎ On server/client when sending a message use socket.emit(โ€˜eventnameโ€™,data). โ€œeventnameโ€ can be any string ๏‚ฎ And data can be any data: even Binary data! ๏‚ฎ On server/client when you want to listen to events-messages use socket.on(โ€˜eventnameโ€™,callbackFunction). ๏‚ฎ Where the callbackFunction is a function that accepts a Data argument : Data sent by the other party.
  • 13. Slide 13 www.edureka.co/mastering-node-jsSlide 13Slide 13Slide 13 ๏‚ฎ A simple example: //Server-side var app = require('express')(); var server = require('http').Server(app); var io = require('socket.io')(server); server.listen(80); app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); //client-side <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost'); socket.on('news', function (data) { console.log(data); socket.emit('my other event', { my: 'data' }); }); </script> Creating Simple Chat Application
  • 14. Slide 14 www.edureka.co/mastering-node-jsSlide 14Slide 14Slide 14 ๏‚ฎ Besides โ€˜connectโ€™, โ€˜messageโ€™ and โ€˜disconnectโ€™ you can use any custom event names ๏‚ฎ You could also have a separation of concerns by namespacing. Namespacing also means, that the same websocket connection is used but is multiplexed var io = require('socket.io').listen(80); var chat = io .of('/chat') .on('connection', function (socket) { socket.emit('a message', { that: 'only' , '/chat': 'will get' }); }); var news = io .of('/news') .on('connection', function (socket) { socket.emit('item', { news: 'item' }); }); <script> var chat = io.connect('http://localhost/chat') , news = io.connect('http://localhost/news'); chat.on('connect', function () { chat.emit('hi!'); }); news.on('news', function () { news.emit('woot'); }); </script> Creating Simple Chat Application
  • 15. Slide 15 www.edureka.co/mastering-node-jsSlide 15 Node.js Developers Use RESTful API With Node.js
  • 16. Slide 16 www.edureka.co/mastering-node-jsSlide 16Slide 16Slide 16 RESTful API With Node.js ๏‚ฎ REST stands for Representational State Transfer. It is an architecture that allows client-server communication through a uniform interface. ๏‚ฎ We will create a Restful Web Service with Node.js to perform CRUD operations ( create, read, update, delete ) ๏‚ฎ By convention, HTTP verbs, such as GET, POST, PUT, and DELETE are mapped to retrieving, creating, updating, and removing the resources specified by the URL
  • 18. Slide 18 www.edureka.co/mastering-node-jsSlide 18 Node.js Developers Have To Debug and Test the Codes
  • 19. Slide 19 www.edureka.co/mastering-node-jsSlide 19Slide 19Slide 19 ๏‚ฎ Node.js has a built in command line debugger. The debugger is invoked by starting your application using the debug keyword, like below : โ€ข node debug server.js var http = require('http'); http.createServer(function (req, res) { debugger; res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); Debugging in Node.js ๏‚ฎ Breakpoints are used to stop the execution and examine the application. ๏‚ฎ One way to add a breakpoint is by adding a line to your application where you want to put the breakpoint. This line should contain the statement debugger;
  • 20. Slide 20 www.edureka.co/mastering-node-jsSlide 20Slide 20Slide 20 TDD Flavor BDD Flavor Unit Testing ๏‚ฎ Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle ๏‚ฎ BDD (Behaviour Driven Development) is a synthesis and refinement of practices stemming from TDD (Test Driven Development) and ATDD (Acceptance Test Driven Development) Testing in Node.js ๏‚ฎ Unit testing is a type of automated testing where you write logic to test discrete parts of your application.
  • 21. Slide 21 www.edureka.co/mastering-node-jsSlide 21Slide 21Slide 21 Mocha is a feature-rich JavaScript test framework running on node.js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any JavaScript testing framework Testing in Node.js