SlideShare uma empresa Scribd logo
1 de 34
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Agenda
Why Express?
1
What is Express.js?
2
Express Routes
3
Express Middlewares
4
Demo
5
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Node.js
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
What is Node.js ?
▪ Node.js is an open source runtime environment for server-side and networking applications and is single threaded.
▪ Uses Google JavaScript V8 Engine to execute code.
▪ It is cross platform environment and can run on OS X, Microsoft Windows, Linux and FreeBSD.
▪ Provides an event driven architecture and non blocking I/O that is optimized and scalable.
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Creating Server using HTTP Module
www.edureka.co/mastering-node-jsEDUREKA ANGULARJS CERTIFICATION TRAINING
HTTP
Import Required Modules
Creating Server
Parse the fetched URL to get pathname
Request file to be read from file system
Creating Header with content type as text or HTML
Generating Response
Listening to port: 3000
▪ To use the HTTP server and client one must require('http')
▪ The HTTP interfaces in Node.js are designed to support many features of the protocol
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
What is Express?
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
What is Express.js?
▪ Web application framework for Node.js
▪ Light-weight and minimalist
▪ Provides boilerplate structure & organization for your web-apps
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Express Installation
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Routes
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Routes
Routing refers to the definition of application end points (URIs) and how they respond to client requests
A route method is derived from one of the HTTP methods, and is attached to an instance of the express class
Route
Methods
Importing Express Module
Creating Express Instance
Callback function
Path (route)
HTTP request
HTTP response
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Routes
app.all(), special routing method (not derived from any HTTP method)
app.all() is used for loading middleware functions at a path for all request methods
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Route Path
• Route paths, in combination with a request
method, define the endpoints at which requests
can be made
• Route paths can be strings, string patterns, or
regular expressions.
• The characters ?, +, *, and () are subsets of their
regular expression counterparts.
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Route Handlers
Provide multiple callback functions which behave like middleware to handle a request
Exception -> Callbacks might invoke next('route') to bypass the remaining route callbacks
A single callback function can handle a route
Next to bypass the remaining route callbacks
Used to impose pre-conditions on a route, then pass control to subsequent routes
(if no reason to proceed with the current route)
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Route Handlers
Route handlers can be in the form of a function, an array of functions, or combinations of both
Creating
Functions
Router handlers in form of functions &
array of functions
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Response Methods
• Methods on the response object (res) for
sending a response to the client
• Terminate the request-response cycle
• If none of these methods are called, the
client request will be left pending
Method Description
res.download() Prompt a file to be downloaded.
res.end() End the response process.
res.json() Send a JSON response.
res.jsonp() Send a JSON response with JSONP support.
res.redirect() Redirect a request.
res.render() Render a view template.
res.send() Send a response of various types.
res.sendFile() Send a file as an octet stream.
res.sendStatus()
Set the response status code and send its string
representation as the response body.
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Routes (app.route)
• Create chainable route handlers for a route path by using app.route()
• Path is specified at a single location
• Creating modular routes is helpful, as it reduces redundancy and typos
Creating chainable route
GET Method
POST Method
PUT Method
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Routes (express.Router)
Creates a router
as a module
Loads a
middleware
function
Defines
Home Route
Define About
Route
➢ Router class to create modular,
mountable route handlers
➢ A Router instance is a complete
middleware and routing system
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Middleware
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Middleware
Middleware functions are functions that have access to the request object (req), the response object (res), and
the next function in the application’s request-response cycle.
next function is invoked to executes the middleware succeeding the current middleware
ServerClients
Request A
Response A
Request B
Response B
Request C
Response C
Request
Object
Response
Object
Next
function
Function B
Middleware
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Middleware
• Execute any code
• Make changes to the request and the response objects
• End the request-response cycle
• Call the next middleware in the stack
Middleware functions performs the following tasks:
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Middleware
HTTP method
Path (route)
HTTP request argument
HTTP response argument
Callback argument to the
middleware function
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Middleware
Uses the requestTime middleware
function
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Application-level middleware
Bind application-level middleware to an instance (app.use() & app.METHOD())
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Router-level middleware
• Router-level middleware binds to an instance of express.Router()
• Works in the same way as application-level middleware
Router middleware i.e.
executed for every router
request
Router middleware i.e.
executed for given path
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Error-handling middleware
• Error-handling middleware always takes four arguments: (err, req, res, next)
• next object will be interpreted as regular middleware and will fail to handle errors
• Define error-handling middleware functions in the same way as other middleware functions
Error Object
Request Object
Response Object
Next Object
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Built-in middleware
• Except express.static, all of the middleware functions that were previously bundled with Express are now in separate modules
• express.static function is responsible for serving static assets such as HTML files, images, etc.
serving static assets
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Independent Module
These middleware and libraries are officially supported by the Connect/Express team:
Modules Description
body-parser Parse incoming request bodies in a middleware before your handler
compression Node.js compression middleware
connect-timeout Times out a request in the Express application framework
cookie-parser Parse Cookie header and populate req.cookies with an object keyed by the cookie names
cookie-session Simple cookie-based session middleware
csurf Node.js CSRF protection middleware
errorhandler Error handler middleware
express-session Create a session middleware
method-override Create a new middleware function to override the req.method property with a new value
morgan Create a new morgan logger middleware function
response-time Creates a middleware that records the response time for requests in HTTP servers
serve-favicon Middleware for serving a favicon
serve-index Serves pages that contain directory listings for a given path
serve-static Middleware function to serve files from within a given root directory
vhost Middleware function to hand off request to handle, for the incoming host
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Template Engines with Express
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Template Engines with Express
• Template engine enables you to use static template files in your application
• Easier to design an HTML page
• Popular template engines: Pug, Mustache, and EJS
• Express application generator uses Jade as its default
Declaring HTML
template using Jade
Rending Template
inside the application
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Template Engines with Express
To render template files, set property in app.js :
• views, the directory where the template files are located
• view engine, the template engine to use
www.edureka.co/mastering-node-jsEDUREKA ANGULARJS CERTIFICATION TRAINING
Database Integration
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js
Database Integration
Database systems supported by Express:
• Cassandra
• Couchbase
• CouchDB
• LevelDB
• MySQL
• MongoDB
• Neo4j
• PostgreSQL
• Redis
• SQL Server
• SQLite
• ElasticSearch
EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/angular-js
Thank You …
Questions/Queries/Feedback

Mais conteúdo relacionado

Mais procurados

Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3Doris Chen
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsANKUSH CHAVAN
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modulesmonikadeshmane
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentationThanh Tuong
 
Top Frontend Framework 2022
Top Frontend Framework 2022Top Frontend Framework 2022
Top Frontend Framework 2022ElenorWisozk
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and reduxCuong Ho
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 

Mais procurados (20)

Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Express node js
Express node jsExpress node js
Express node js
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
Top Frontend Framework 2022
Top Frontend Framework 2022Top Frontend Framework 2022
Top Frontend Framework 2022
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 

Semelhante a Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + ExpressJS | Edureka

What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...Edureka!
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)Daniel Bryant
 
Javascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsJavascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsSalesforce Developers
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN StackNir Noy
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solrlucenerevolution
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
ExpressJS-Introduction.pdf
ExpressJS-Introduction.pdfExpressJS-Introduction.pdf
ExpressJS-Introduction.pdfBareen Shaikh
 
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSMERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSannalakshmi35
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Arrow Consulting & Design
 
Azure in Developer Perspective
Azure in Developer PerspectiveAzure in Developer Perspective
Azure in Developer Perspectiverizaon
 
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Juarez Junior
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Osconvijayrvr
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Web services in java
Web services in javaWeb services in java
Web services in javamaabujji
 
Rajiv ranjan resume-us
Rajiv ranjan  resume-usRajiv ranjan  resume-us
Rajiv ranjan resume-usRajiv Ranjan
 
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...Juarez Junior
 

Semelhante a Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + ExpressJS | Edureka (20)

What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
 
Oracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node finalOracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node final
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
Javascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsJavascript-heavy Salesforce Applications
Javascript-heavy Salesforce Applications
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
ExpressJS-Introduction.pdf
ExpressJS-Introduction.pdfExpressJS-Introduction.pdf
ExpressJS-Introduction.pdf
 
23003468463PPT.pptx
23003468463PPT.pptx23003468463PPT.pptx
23003468463PPT.pptx
 
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSMERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
 
Azure cosmosdb
Azure cosmosdbAzure cosmosdb
Azure cosmosdb
 
Azure in Developer Perspective
Azure in Developer PerspectiveAzure in Developer Perspective
Azure in Developer Perspective
 
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
Day7
Day7Day7
Day7
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Web services in java
Web services in javaWeb services in java
Web services in java
 
Rajiv ranjan resume-us
Rajiv ranjan  resume-usRajiv ranjan  resume-us
Rajiv ranjan resume-us
 
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
 

Mais de 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 | EdurekaEdureka!
 
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 | EdurekaEdureka!
 
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 | EdurekaEdureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
 
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 | EdurekaEdureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
 
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| EdurekaEdureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
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 | EdurekaEdureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
 

Mais de 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
 
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
 
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
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | 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
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | 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
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | 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
 
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
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Último

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + ExpressJS | Edureka

  • 1.
  • 2. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Agenda Why Express? 1 What is Express.js? 2 Express Routes 3 Express Middlewares 4 Demo 5
  • 3. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Node.js
  • 4. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js What is Node.js ? ▪ Node.js is an open source runtime environment for server-side and networking applications and is single threaded. ▪ Uses Google JavaScript V8 Engine to execute code. ▪ It is cross platform environment and can run on OS X, Microsoft Windows, Linux and FreeBSD. ▪ Provides an event driven architecture and non blocking I/O that is optimized and scalable.
  • 5. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Creating Server using HTTP Module
  • 6. www.edureka.co/mastering-node-jsEDUREKA ANGULARJS CERTIFICATION TRAINING HTTP Import Required Modules Creating Server Parse the fetched URL to get pathname Request file to be read from file system Creating Header with content type as text or HTML Generating Response Listening to port: 3000 ▪ To use the HTTP server and client one must require('http') ▪ The HTTP interfaces in Node.js are designed to support many features of the protocol
  • 7. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js What is Express?
  • 8. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js What is Express.js? ▪ Web application framework for Node.js ▪ Light-weight and minimalist ▪ Provides boilerplate structure & organization for your web-apps
  • 9. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Express Installation
  • 10. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Routes
  • 11. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Routes Routing refers to the definition of application end points (URIs) and how they respond to client requests A route method is derived from one of the HTTP methods, and is attached to an instance of the express class Route Methods Importing Express Module Creating Express Instance Callback function Path (route) HTTP request HTTP response
  • 12. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Routes app.all(), special routing method (not derived from any HTTP method) app.all() is used for loading middleware functions at a path for all request methods
  • 13. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Route Path • Route paths, in combination with a request method, define the endpoints at which requests can be made • Route paths can be strings, string patterns, or regular expressions. • The characters ?, +, *, and () are subsets of their regular expression counterparts.
  • 14. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Route Handlers Provide multiple callback functions which behave like middleware to handle a request Exception -> Callbacks might invoke next('route') to bypass the remaining route callbacks A single callback function can handle a route Next to bypass the remaining route callbacks Used to impose pre-conditions on a route, then pass control to subsequent routes (if no reason to proceed with the current route)
  • 15. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Route Handlers Route handlers can be in the form of a function, an array of functions, or combinations of both Creating Functions Router handlers in form of functions & array of functions
  • 16. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Response Methods • Methods on the response object (res) for sending a response to the client • Terminate the request-response cycle • If none of these methods are called, the client request will be left pending Method Description res.download() Prompt a file to be downloaded. res.end() End the response process. res.json() Send a JSON response. res.jsonp() Send a JSON response with JSONP support. res.redirect() Redirect a request. res.render() Render a view template. res.send() Send a response of various types. res.sendFile() Send a file as an octet stream. res.sendStatus() Set the response status code and send its string representation as the response body.
  • 17. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Routes (app.route) • Create chainable route handlers for a route path by using app.route() • Path is specified at a single location • Creating modular routes is helpful, as it reduces redundancy and typos Creating chainable route GET Method POST Method PUT Method
  • 18. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Routes (express.Router) Creates a router as a module Loads a middleware function Defines Home Route Define About Route ➢ Router class to create modular, mountable route handlers ➢ A Router instance is a complete middleware and routing system
  • 19. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Middleware
  • 20. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Middleware Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle. next function is invoked to executes the middleware succeeding the current middleware ServerClients Request A Response A Request B Response B Request C Response C Request Object Response Object Next function Function B Middleware
  • 21. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Middleware • Execute any code • Make changes to the request and the response objects • End the request-response cycle • Call the next middleware in the stack Middleware functions performs the following tasks:
  • 22. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Middleware HTTP method Path (route) HTTP request argument HTTP response argument Callback argument to the middleware function
  • 23. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Middleware Uses the requestTime middleware function
  • 24. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Application-level middleware Bind application-level middleware to an instance (app.use() & app.METHOD())
  • 25. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Router-level middleware • Router-level middleware binds to an instance of express.Router() • Works in the same way as application-level middleware Router middleware i.e. executed for every router request Router middleware i.e. executed for given path
  • 26. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Error-handling middleware • Error-handling middleware always takes four arguments: (err, req, res, next) • next object will be interpreted as regular middleware and will fail to handle errors • Define error-handling middleware functions in the same way as other middleware functions Error Object Request Object Response Object Next Object
  • 27. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Built-in middleware • Except express.static, all of the middleware functions that were previously bundled with Express are now in separate modules • express.static function is responsible for serving static assets such as HTML files, images, etc. serving static assets
  • 28. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Independent Module These middleware and libraries are officially supported by the Connect/Express team: Modules Description body-parser Parse incoming request bodies in a middleware before your handler compression Node.js compression middleware connect-timeout Times out a request in the Express application framework cookie-parser Parse Cookie header and populate req.cookies with an object keyed by the cookie names cookie-session Simple cookie-based session middleware csurf Node.js CSRF protection middleware errorhandler Error handler middleware express-session Create a session middleware method-override Create a new middleware function to override the req.method property with a new value morgan Create a new morgan logger middleware function response-time Creates a middleware that records the response time for requests in HTTP servers serve-favicon Middleware for serving a favicon serve-index Serves pages that contain directory listings for a given path serve-static Middleware function to serve files from within a given root directory vhost Middleware function to hand off request to handle, for the incoming host
  • 29. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Template Engines with Express
  • 30. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Template Engines with Express • Template engine enables you to use static template files in your application • Easier to design an HTML page • Popular template engines: Pug, Mustache, and EJS • Express application generator uses Jade as its default Declaring HTML template using Jade Rending Template inside the application
  • 31. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Template Engines with Express To render template files, set property in app.js : • views, the directory where the template files are located • view engine, the template engine to use
  • 33. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/mastering-node-js Database Integration Database systems supported by Express: • Cassandra • Couchbase • CouchDB • LevelDB • MySQL • MongoDB • Neo4j • PostgreSQL • Redis • SQL Server • SQLite • ElasticSearch
  • 34. EDUREKA NODE.JS CERTIFICATION TRAINING www.edureka.co/angular-js Thank You … Questions/Queries/Feedback