SlideShare a Scribd company logo
1 of 16
Node.JsNode.Js
Ayush Mishra
Knoldus Software LLP
Ayush Mishra
Knoldus Software LLP
Topics CoveredTopics Covered
1. What is Node.js
2. Features Of Node.js
3. Testing Node Installation
4. Create HTTP server
5. URL Module
5. Event-Driven and Asynchronous Platform
6. Demo Application
1. What is Node.js
2. Features Of Node.js
3. Testing Node Installation
4. Create HTTP server
5. URL Module
5. Event-Driven and Asynchronous Platform
6. Demo Application
What is Node.jsWhat is Node.js
Created by Ryan Dahl strating in 2009.
Javascript on the server.
A software platform that is used for easily building fast, scalable network
applications (especially server-side) applications.
Built on Google V8's Engine.
Not executed in a web browser. Executed as a server-side JavaScript application.
Created by Ryan Dahl strating in 2009.
Javascript on the server.
A software platform that is used for easily building fast, scalable network
applications (especially server-side) applications.
Built on Google V8's Engine.
Not executed in a web browser. Executed as a server-side JavaScript application.
Developers can write web applications in one language.
Uses event-driven, non-blocking I/O model for building scalable network application.
Node.js ships with a lot of useful modules. Thus, Node.js is really two things: a runtime
environment and a library.
Uses npm (Node Package Manager) utility to install third party node modules.
Node.js contains a built-in HTTP server library:-making it possible to run a web server
without the use of external software, such as Apache and allowing more control of how
the web server works.
Developers can write web applications in one language.
Uses event-driven, non-blocking I/O model for building scalable network application.
Node.js ships with a lot of useful modules. Thus, Node.js is really two things: a runtime
environment and a library.
Uses npm (Node Package Manager) utility to install third party node modules.
Node.js contains a built-in HTTP server library:-making it possible to run a web server
without the use of external software, such as Apache and allowing more control of how
the web server works.
FeaturesFeatures
Testing Node InstallationTesting Node Installation
1)Create a file 'hello.js'
2) console.log(“Hello Knoldus”)
1)Create a file 'hello.js'
2) console.log(“Hello Knoldus”)
HTTP ServerHTTP Server
http.createServer([requestListener])
server.listen(port, [hostname], [callback])
server.listen(path, [callback])
server.close()
http.createServer([requestListener])
server.listen(port, [hostname], [callback])
server.listen(path, [callback])
server.close()
HTTP ServerHTTP Server
var http = require('http');
var content = '<html><body><p>Hello World</p><script type=”text/javascript”'
+'>alert(“Hi!”);</script></body></html>';
http.createServer(function (request, response) {
if (request.url === '/') {
response.end(content);
}else if (request.url === '/login') {
response.end('Welcome To Login Page');
}else{
response.end('Wrong URL');
}
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/.');
var http = require('http');
var content = '<html><body><p>Hello World</p><script type=”text/javascript”'
+'>alert(“Hi!”);</script></body></html>';
http.createServer(function (request, response) {
if (request.url === '/') {
response.end(content);
}else if (request.url === '/login') {
response.end('Welcome To Login Page');
}else{
response.end('Wrong URL');
}
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/.');
 Call require('url') to use it.
 url.parse(urlStr, parseQueryString = false): Parses a URL string and returns an object
which contains the various parts of the URL.
 url.format(urlObj): Accepts a parsed URL object and returns the string. Does the
reverse of url.parse().
 url.resolve(from, to): Resolves a given URL relative to a base URL as a browser
would for an anchor tag.
 Call require('url') to use it.
 url.parse(urlStr, parseQueryString = false): Parses a URL string and returns an object
which contains the various parts of the URL.
 url.format(urlObj): Accepts a parsed URL object and returns the string. Does the
reverse of url.parse().
 url.resolve(from, to): Resolves a given URL relative to a base URL as a browser
would for an anchor tag.
URLURL
URLURL
Event-Driven and Asynchronous PlatformEvent-Driven and Asynchronous Platform
$.post('/resource.json', function (data) { // I/O doesn’t block execution
console.log(data);
});
Console.log(“hello”)
var data = $.post('/resource.json');//I/O blocks execution
console.log(data);
Console.log(“hello”)
$.post('/resource.json', function (data) { // I/O doesn’t block execution
console.log(data);
});
Console.log(“hello”)
var data = $.post('/resource.json');//I/O blocks execution
console.log(data);
Console.log(“hello”)
1) var result = database.query("SELECT * FROM employee");
console.log("Hello World");
2) database.query("SELECT * FROM employee", function(rows) {
var result = rows;
});
console.log("Hello World");
3)var http = require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
1) var result = database.query("SELECT * FROM employee");
console.log("Hello World");
2) database.query("SELECT * FROM employee", function(rows) {
var result = rows;
});
console.log("Hello World");
3)var http = require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
Login ApplicationLogin Application
https://github.com/knoldus/Node.js_UserLogin_Templatehttps://github.com/knoldus/Node.js_UserLogin_Template
ThanksThanks

More Related Content

What's hot

Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And GroovyKen Kousen
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
AWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAmazon Web Services
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongoMax Kremer
 
Using OpenStack With Fog
Using OpenStack With FogUsing OpenStack With Fog
Using OpenStack With FogMike Hagedorn
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearchErhwen Kuo
 
Meetup bangalore 9_novupdated
Meetup bangalore 9_novupdatedMeetup bangalore 9_novupdated
Meetup bangalore 9_novupdatedD.Rajesh Kumar
 
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...Amazon Web Services
 
Drupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + DockerDrupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + DockerRoald Umandal
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redisErhwen Kuo
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframeworkErhwen Kuo
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websitesoazabir
 
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018Chris Gillum
 
03 integrate webapisignalr
03 integrate webapisignalr03 integrate webapisignalr
03 integrate webapisignalrErhwen Kuo
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassBrian Caauwe
 
(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLI(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLIAmazon Web Services
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Yevgeniy Brikman
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsSarvesh Kushwaha
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 

What's hot (20)

Google App Engine With Java And Groovy
Google App Engine With Java And GroovyGoogle App Engine With Java And Groovy
Google App Engine With Java And Groovy
 
Firebase slide
Firebase slideFirebase slide
Firebase slide
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
AWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar Series
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongo
 
Using OpenStack With Fog
Using OpenStack With FogUsing OpenStack With Fog
Using OpenStack With Fog
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
Meetup bangalore 9_novupdated
Meetup bangalore 9_novupdatedMeetup bangalore 9_novupdated
Meetup bangalore 9_novupdated
 
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
 
Drupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + DockerDrupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + Docker
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redis
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframework
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
 
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
 
03 integrate webapisignalr
03 integrate webapisignalr03 integrate webapisignalr
03 integrate webapisignalr
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking Glass
 
(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLI(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLI
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC Applications
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 

Similar to An Overview of Node.js

Node.js introduction
Node.js introductionNode.js introduction
Node.js introductionParth Joshi
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejsAmit Thakkar
 
Getting started with node JS
Getting started with node JSGetting started with node JS
Getting started with node JSHamdi Hmidi
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015Nir Noy
 
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
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developerEdureka!
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperEdureka!
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsBudh Ram Gurung
 

Similar to An Overview of Node.js (20)

Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
5.node js
5.node js5.node js
5.node js
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
Getting started with node JS
Getting started with node JSGetting started with node JS
Getting started with node JS
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
hacking with node.JS
hacking with node.JShacking with node.JS
hacking with node.JS
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
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
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Proposal
ProposalProposal
Proposal
 
Android networking-2
Android networking-2Android networking-2
Android networking-2
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Node js getting started
Node js getting startedNode js getting started
Node js getting started
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web Applications
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
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
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
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
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

An Overview of Node.js

  • 1. Node.JsNode.Js Ayush Mishra Knoldus Software LLP Ayush Mishra Knoldus Software LLP
  • 2. Topics CoveredTopics Covered 1. What is Node.js 2. Features Of Node.js 3. Testing Node Installation 4. Create HTTP server 5. URL Module 5. Event-Driven and Asynchronous Platform 6. Demo Application 1. What is Node.js 2. Features Of Node.js 3. Testing Node Installation 4. Create HTTP server 5. URL Module 5. Event-Driven and Asynchronous Platform 6. Demo Application
  • 3. What is Node.jsWhat is Node.js Created by Ryan Dahl strating in 2009. Javascript on the server. A software platform that is used for easily building fast, scalable network applications (especially server-side) applications. Built on Google V8's Engine. Not executed in a web browser. Executed as a server-side JavaScript application. Created by Ryan Dahl strating in 2009. Javascript on the server. A software platform that is used for easily building fast, scalable network applications (especially server-side) applications. Built on Google V8's Engine. Not executed in a web browser. Executed as a server-side JavaScript application.
  • 4. Developers can write web applications in one language. Uses event-driven, non-blocking I/O model for building scalable network application. Node.js ships with a lot of useful modules. Thus, Node.js is really two things: a runtime environment and a library. Uses npm (Node Package Manager) utility to install third party node modules. Node.js contains a built-in HTTP server library:-making it possible to run a web server without the use of external software, such as Apache and allowing more control of how the web server works. Developers can write web applications in one language. Uses event-driven, non-blocking I/O model for building scalable network application. Node.js ships with a lot of useful modules. Thus, Node.js is really two things: a runtime environment and a library. Uses npm (Node Package Manager) utility to install third party node modules. Node.js contains a built-in HTTP server library:-making it possible to run a web server without the use of external software, such as Apache and allowing more control of how the web server works. FeaturesFeatures
  • 5. Testing Node InstallationTesting Node Installation 1)Create a file 'hello.js' 2) console.log(“Hello Knoldus”) 1)Create a file 'hello.js' 2) console.log(“Hello Knoldus”)
  • 7. http.createServer([requestListener]) server.listen(port, [hostname], [callback]) server.listen(path, [callback]) server.close() http.createServer([requestListener]) server.listen(port, [hostname], [callback]) server.listen(path, [callback]) server.close() HTTP ServerHTTP Server
  • 8.
  • 9. var http = require('http'); var content = '<html><body><p>Hello World</p><script type=”text/javascript”' +'>alert(“Hi!”);</script></body></html>'; http.createServer(function (request, response) { if (request.url === '/') { response.end(content); }else if (request.url === '/login') { response.end('Welcome To Login Page'); }else{ response.end('Wrong URL'); } }).listen(8080, 'localhost'); console.log('Server running at http://localhost:8080/.'); var http = require('http'); var content = '<html><body><p>Hello World</p><script type=”text/javascript”' +'>alert(“Hi!”);</script></body></html>'; http.createServer(function (request, response) { if (request.url === '/') { response.end(content); }else if (request.url === '/login') { response.end('Welcome To Login Page'); }else{ response.end('Wrong URL'); } }).listen(8080, 'localhost'); console.log('Server running at http://localhost:8080/.');
  • 10.  Call require('url') to use it.  url.parse(urlStr, parseQueryString = false): Parses a URL string and returns an object which contains the various parts of the URL.  url.format(urlObj): Accepts a parsed URL object and returns the string. Does the reverse of url.parse().  url.resolve(from, to): Resolves a given URL relative to a base URL as a browser would for an anchor tag.  Call require('url') to use it.  url.parse(urlStr, parseQueryString = false): Parses a URL string and returns an object which contains the various parts of the URL.  url.format(urlObj): Accepts a parsed URL object and returns the string. Does the reverse of url.parse().  url.resolve(from, to): Resolves a given URL relative to a base URL as a browser would for an anchor tag. URLURL
  • 12. Event-Driven and Asynchronous PlatformEvent-Driven and Asynchronous Platform
  • 13. $.post('/resource.json', function (data) { // I/O doesn’t block execution console.log(data); }); Console.log(“hello”) var data = $.post('/resource.json');//I/O blocks execution console.log(data); Console.log(“hello”) $.post('/resource.json', function (data) { // I/O doesn’t block execution console.log(data); }); Console.log(“hello”) var data = $.post('/resource.json');//I/O blocks execution console.log(data); Console.log(“hello”)
  • 14. 1) var result = database.query("SELECT * FROM employee"); console.log("Hello World"); 2) database.query("SELECT * FROM employee", function(rows) { var result = rows; }); console.log("Hello World"); 3)var http = require("http"); function onRequest(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); } http.createServer(onRequest).listen(8888); console.log("Server has started."); 1) var result = database.query("SELECT * FROM employee"); console.log("Hello World"); 2) database.query("SELECT * FROM employee", function(rows) { var result = rows; }); console.log("Hello World"); 3)var http = require("http"); function onRequest(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); } http.createServer(onRequest).listen(8888); console.log("Server has started.");

Editor's Notes

  1. If you want to create more serious frontend stuff or you want to add more feature in your web page, we use jquery and prototype like this, whenever we felt like spicing up web page But this is still frontend stuff. Here you are just a javascript user, javascript developer. That&amp;apos;s why node.js is created, javascript on the server. Node uses V8 , the virtual machine that powers Google Chrome, for server-side pro- gramming IT is build on google chrome runtime. It uses v8, the same run time environment, that google chrome uses. Actually reason is. Javasript is one context, which lives in browser. It defines only what you can do with the language. It does not say much about what lanuage itself can do. Node.js is anothe context. It allows you to run javascript as backend code outside a browser.In order to execute, javascript, that you intend to run in backend, it needs to be well interpreted and well execute , this is what node.js does with the use of v8 virtual macine. V8 gives a huge boost performance and it is developed by google. Because it prefers straight compilation into native machine code. And The compiled code is additionally optimized (and re-optimized) dynamically at runtime .
  2. npm is the official package manager for Node.js. As of Node.js version 0.6.3, npm is bundled and installed automatically with the environment.[1] npm runs through the command line and manages dependencies for an application. It also allows users to install Node.js applications that are available on the npm registry. npm is written entirely in JavaScript, and runs on the Node.js platform. The Node Package Manager (npm; https://github.com/isaacs/npm) is a util- ity that comes bundled with Node. It offers a great deal of functionality, allowing you to easily install third-party Node modules and globally publish any Node modules
  3. Node.js contains a built-in HTTP server library:-making it possible to run a web server without the use of external software, such asApache  You can use use https server by requiring http module. http module ships with node.js and
  4. Asynchronous and evented: the browser:- Node provides an event-driven and asynchronous platform for server-side JavaScript. It brings JavaScript to the server in much the same way a browser brings JavaScript to the client. Node.js is evet driven and non-blocking while handling i/o operation. event driven programming means where flow of program is detrmined by events such as mouse click, key press As we know Synchronous mode, the thread waits for I/O to complete before proceeding further. The thread will be in a “wait” state. However in the case of asynchronous operation, the thread will not wait for I/O to finish. It will continue with the processing till it gets interrupted Since node.js runs in a single thread, so you should use asychronus style of coading.
  5. Here you can see operation does not block execution. Here atually what is happening. Response from reourese.json would be stored in data. After that console.log function will execute. It will not execute untill it is ready. Browser is single threaded. If this request took 2 mins or 3 mins, any other event happening would have to wait for completion of this request. You can image a poor user experince, animation can be paused. Thankfully it will not happen in case of node.js. When any operation happens in the browser, it will happen out side of the event loop and then event is emitted when this operation is finished. This is called call back function. This will happen asynchronusly. It will not bloack the script execution. It will allow browser to be responsive to client and handle a lot of interactivity on the page
  6. it&amp;apos;s just an example. The first line queries a database for lots of rows, the second line puts &amp;quot;Hello World&amp;quot; to the console. Let&amp;apos;s assume that the database query is really slow, that it has to read an awful lot of rows, which takes several seconds. The way we have written this code, the JavaScript interpreter of Node.js first has to read the complete result set from the database, and then it can execute the console.log()function. The execution model of Node.js is different - there is only one single process. If there is a slow database query somewhere in this process, this affects the whole process - everything comes to a halt until the slow query has finished. We can understand this concept by analyzing a rewritten version of our problematic code: