SlideShare a Scribd company logo
1 of 21
 Express.js is a web framework for Node.js. It is a
fast, robust and asynchronous in nature.
 ExpressJS is a web application framework that
provides you with a simple API to build websites,
web apps and back ends.
 Install express framework globally to create web
application using node terminal.
npm install –g express
npm install express --save
npm install –g nodemon
var express = require('express')
var app = express()
app.get('/',function(req,res){
res.send("Hello Govardhan")
});
app.listen(2022)
 Routing is made from the word route. It is used to
determine the specific behavior of an application.
 It specifies how an application responds to a client
request to a particular route, URI or path and a
specific HTTP request method (GET, POST, etc.). It
can handle different types of HTTP requests.
app.method(path, handler)
 MVC is the most popular & useful structure for web application and it
describes as
▪ Model – It can handle the database
▪ View – It can handle the client-side web pages
▪ Controller – It can control the request & response of Model & View
 Error handling in Express is done using middleware.
But this middleware has special properties. The error
handling middleware are defined in the same way as
other middleware functions, except that error-
handling functions must have four arguments instead
of three – err, req, res, next.
 For error handling, we have the next(err) function. A
call to this function skips all middleware and matches
us to the next error handler for that route.
var express = require('express');
var app = express();
app.get('/', function(req, res){
//Create an error and pass it to the next function
var err = new Error();
next(err);
});
//An error handling middleware
app.use(function(err, req, res, next) {
res.status(500);
res.send("Oops, Something went wrong.")
});
app.listen(2022);
 Express uses the Debug module to internally log
information about route matching, middleware
functions, application mode, etc.
 To see all internal logs used in Express, set the
DEBUG environment variable to Express:* when
starting the app −
DEBUG = express:* node index.js
 A template engine enables you to use static template files
in your application. At runtime, the template engine
replaces variables in a template file with actual values, and
transforms the template into an HTML file sent to the
client. This approach makes it easier to design an HTML
page.
 Some popular template engines that work with Express
are Pug, Mustache, and EJS.
npm install pug --save
SimplePug.pug
doctype html
html
head
title=title
body
h1(align=alignment)=myHeading
SimplePug.js
var express = require('express');
var app = express();
app.set('view engine','pug');
app.get('/',function(req,res){
res.render('SimplePug',{
title: "Template Engine",
myHeading: "Pug Template",
alignment: "center"
});
});
app.listen(2022,function(){
console.log("Sever Running");
});
 Process manager is a container for applications that
facilitates deployment, provides high availability, and
enables you to manage the application at runtime.
 It is helpful to –
 Restart the app automatically if it crashes.
 Gain insights into runtime performance and resource
consumption.
 Modify settings dynamically to improve performance.
 Control clustering.
 RESTful web services are basically REST
architecture based web services.
 RESTful web services are light-weight, highly
scalable and maintainable and are very commonly
used to create APIs for web-based applications.
 REST – REpresentational State Transfer.
 It is web standard based architecture and uses HTTP
protocol.
 It revolves around resource where every component
is a resource and a resource is accessed by a common
interface using HTTP methods.
 Four HTTP methods are commonly used in REST
based architecture:
1. GET – Provides a read only access to a resource.
2. POST – Used to create a new resource.
3. DELETE – Used to remove a resource.
4. PUT – Used to update an existing resource or create a
new resource.
 Uniform interface constraint defines the interface
between clients and servers.
 Four principles of uniform interface:
1. Identifying Resources
2. Manipulation of Resources through Representations
3. Self-descriptive messages
4. Hypermedia as the Engine of Application State
 Each resource in REST architecture is identified
by its URI (Uniform Resource Identifier).
 The generic URI syntax as shown below:
<protocol>://<service-name>/<ResourceType>/<ResourceID>
Cont…
1. A trailing forward slash (/) should not be included in URIs
2. Forward slash separator (/) must be used to indicate a hierarchical
relationship
3. Hyphens (-) should be used to improve the readability of URIs
4. Underscores (_) should not be used in URIs
5. Lowercase letters should be preferred in URI paths
6. File extensions should not be included in URIs
7. Should the endpoint name be plural nouns

More Related Content

Similar to ExpressJS and REST API.pptx

Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyPayal Jain
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsSrdjan Strbanovic
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIsKnoldus Inc.
 
Weekly Tech Session
Weekly Tech SessionWeekly Tech Session
Weekly Tech SessionPravin Vaja
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
Node Session - 3
Node Session - 3Node Session - 3
Node Session - 3Bhavin Shah
 
Rest service in mule
Rest service in mule Rest service in mule
Rest service in mule Harish43
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJerry Kurian
 
Express Generator.pdf
Express Generator.pdfExpress Generator.pdf
Express Generator.pdfBareen Shaikh
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET Journal
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling ResolutionDEEPAK KHETAWAT
 

Similar to ExpressJS and REST API.pptx (20)

Rest web service
Rest web serviceRest web service
Rest web service
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Javascript Basic RESTful
Javascript Basic RESTfulJavascript Basic RESTful
Javascript Basic RESTful
 
Weekly Tech Session
Weekly Tech SessionWeekly Tech Session
Weekly Tech Session
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Node Session - 3
Node Session - 3Node Session - 3
Node Session - 3
 
Rest service in mule
Rest service in mule Rest service in mule
Rest service in mule
 
Express
ExpressExpress
Express
 
Rest Service In Mule
Rest Service In Mule Rest Service In Mule
Rest Service In Mule
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
Express Generator.pdf
Express Generator.pdfExpress Generator.pdf
Express Generator.pdf
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce Site
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 

More from Govardhan Bhavani (17)

Angular Application Setup.pptx
Angular Application Setup.pptxAngular Application Setup.pptx
Angular Application Setup.pptx
 
Files.pptx
Files.pptxFiles.pptx
Files.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
NodeJS.pptx
NodeJS.pptxNodeJS.pptx
NodeJS.pptx
 
Angular.pptx
Angular.pptxAngular.pptx
Angular.pptx
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Maven.pptx
Maven.pptxMaven.pptx
Maven.pptx
 
Configure & Version Control-Git.pptx
Configure & Version Control-Git.pptxConfigure & Version Control-Git.pptx
Configure & Version Control-Git.pptx
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
 
Agile XP.pptx
Agile XP.pptxAgile XP.pptx
Agile XP.pptx
 
Ajax
AjaxAjax
Ajax
 
Ruby
RubyRuby
Ruby
 
PHP
PHPPHP
PHP
 
CSS
CSSCSS
CSS
 
Unit 1part-2 forms & frames
Unit 1part-2 forms & framesUnit 1part-2 forms & frames
Unit 1part-2 forms & frames
 
Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

ExpressJS and REST API.pptx

  • 1.
  • 2.  Express.js is a web framework for Node.js. It is a fast, robust and asynchronous in nature.  ExpressJS is a web application framework that provides you with a simple API to build websites, web apps and back ends.
  • 3.  Install express framework globally to create web application using node terminal. npm install –g express npm install express --save npm install –g nodemon
  • 4. var express = require('express') var app = express() app.get('/',function(req,res){ res.send("Hello Govardhan") }); app.listen(2022)
  • 5.  Routing is made from the word route. It is used to determine the specific behavior of an application.  It specifies how an application responds to a client request to a particular route, URI or path and a specific HTTP request method (GET, POST, etc.). It can handle different types of HTTP requests. app.method(path, handler)
  • 6.  MVC is the most popular & useful structure for web application and it describes as ▪ Model – It can handle the database ▪ View – It can handle the client-side web pages ▪ Controller – It can control the request & response of Model & View
  • 7.
  • 8.  Error handling in Express is done using middleware. But this middleware has special properties. The error handling middleware are defined in the same way as other middleware functions, except that error- handling functions must have four arguments instead of three – err, req, res, next.  For error handling, we have the next(err) function. A call to this function skips all middleware and matches us to the next error handler for that route.
  • 9. var express = require('express'); var app = express(); app.get('/', function(req, res){ //Create an error and pass it to the next function var err = new Error(); next(err); }); //An error handling middleware app.use(function(err, req, res, next) { res.status(500); res.send("Oops, Something went wrong.") }); app.listen(2022);
  • 10.  Express uses the Debug module to internally log information about route matching, middleware functions, application mode, etc.  To see all internal logs used in Express, set the DEBUG environment variable to Express:* when starting the app − DEBUG = express:* node index.js
  • 11.  A template engine enables you to use static template files in your application. At runtime, the template engine replaces variables in a template file with actual values, and transforms the template into an HTML file sent to the client. This approach makes it easier to design an HTML page.  Some popular template engines that work with Express are Pug, Mustache, and EJS. npm install pug --save
  • 12. SimplePug.pug doctype html html head title=title body h1(align=alignment)=myHeading SimplePug.js var express = require('express'); var app = express(); app.set('view engine','pug'); app.get('/',function(req,res){ res.render('SimplePug',{ title: "Template Engine", myHeading: "Pug Template", alignment: "center" }); }); app.listen(2022,function(){ console.log("Sever Running"); });
  • 13.  Process manager is a container for applications that facilitates deployment, provides high availability, and enables you to manage the application at runtime.  It is helpful to –  Restart the app automatically if it crashes.  Gain insights into runtime performance and resource consumption.  Modify settings dynamically to improve performance.  Control clustering.
  • 14.
  • 15.  RESTful web services are basically REST architecture based web services.  RESTful web services are light-weight, highly scalable and maintainable and are very commonly used to create APIs for web-based applications.
  • 16.  REST – REpresentational State Transfer.  It is web standard based architecture and uses HTTP protocol.  It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP methods.
  • 17.  Four HTTP methods are commonly used in REST based architecture: 1. GET – Provides a read only access to a resource. 2. POST – Used to create a new resource. 3. DELETE – Used to remove a resource. 4. PUT – Used to update an existing resource or create a new resource.
  • 18.
  • 19.  Uniform interface constraint defines the interface between clients and servers.  Four principles of uniform interface: 1. Identifying Resources 2. Manipulation of Resources through Representations 3. Self-descriptive messages 4. Hypermedia as the Engine of Application State
  • 20.  Each resource in REST architecture is identified by its URI (Uniform Resource Identifier).  The generic URI syntax as shown below: <protocol>://<service-name>/<ResourceType>/<ResourceID> Cont…
  • 21. 1. A trailing forward slash (/) should not be included in URIs 2. Forward slash separator (/) must be used to indicate a hierarchical relationship 3. Hyphens (-) should be used to improve the readability of URIs 4. Underscores (_) should not be used in URIs 5. Lowercase letters should be preferred in URI paths 6. File extensions should not be included in URIs 7. Should the endpoint name be plural nouns