67% found this document useful (3 votes)
819 views

Express JS

This document provides an overview of the Express web application framework. It discusses key features such as quick development pace, flexibility, and pluggability. It also covers installation, routing, middleware, templating engines, basic usage including routes and ports, and provides an example Express app. The document concludes that Express is a common Node.js framework that helps fast-track development of server-side apps.

Uploaded by

Vaishnavi Umekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
67% found this document useful (3 votes)
819 views

Express JS

This document provides an overview of the Express web application framework. It discusses key features such as quick development pace, flexibility, and pluggability. It also covers installation, routing, middleware, templating engines, basic usage including routes and ports, and provides an example Express app. The document concludes that Express is a common Node.js framework that helps fast-track development of server-side apps.

Uploaded by

Vaishnavi Umekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Web Application Framework

CONTENTS

 Introduction
 Features
 Installation
 Routing and HTTP methods
 Middleware
 Templating
 Working
 Example
 Conclusion
 References
INTRODUCTION

 What is Express ?
• Express.js is a web application framework Developed by
that is built on top of Node JS.  TJ Holowaychuk
• Express provides a minimal interface to build
our applications. It provides us the tools that Released in the
are required to build our app. market on 22nd of
• It is flexible as there are numerous modules May, 2010
available on npm, which can be directly
plugged into.
• Why Express ?

• Unlike its competitors like Rails and Django, which


have an opinionated way of building applications,
Express has no "best way" to do something.
• It is very flexible and pluggable.
FEATURES

 quickens the development pace of a web application.


 helps in creating mobile and web application of single- page,
multi-page, and hybrid types
 work with various templating engines such as Pug, Mustache,
and EJS.
 It makes the integration process with databases such as
MongoDB, Redis, MySQL effortless.
INSTALLATION

• In order to install Express.js we need Node.js already installed.


Node.js Installation

https://nodejs.org/en/download/
FIG: Server architecture of Express.js
• Once you are done with Node.js installation, the next step is to
Install Express.

Step 1.
npm init
Step 2.
npm install -g express
Step 3.
npm install express --save
NPM

 NPM (Node Package Manager) Installation

 NPM is the default package manager for Node.js that is


completely written in Javascript.

 In order to install any module using npm: 


Npm  install  package_name
Routing and HTTP methods

Routing refers to the process of determining a specific behavior


of an application.

structure of Routing in Express:

app.METHOD(PATH, HANDLER)
 Four main HTTP methods that can be supplied within the request.
 These methods help in specifying the operation requested by the user.
Method Description
The HTTP GET method helps in requesting for the representation of a
1. GET specific resource by the client. The requests having GET just retrieves data
and without causing any effect.
The HTTP POST method helps in requesting the server to accept the data
2. POST that is enclosed within the request as a new object of the resource as
identified by the URI.

The HTTP PUT method helps in requesting the server to accept the data
3. PUT that is enclosed within the request as an alteration to the existing object
which is identified by the provided URI.

The HTTP DELETE method helps in requesting the server to delete a specific
4. DELETE resource from the destination.
MIDDLEWARE

These functions are capable of performing the below-listed tasks:

• Execution of any code


• Modify the request and the response objects.
• End applications request-response cycle.
• Call the next middleware present in the cycle.
TEMPLATING

Template engines that work well with Express.js :

 Pug (Jade)
 mustache
 dust
 handlebars
 hogan
 liquor
 toffee
 underscore
 walrus
 whiskers
WORKING

Express.js is a popular framework for organizing your code.


Step 1:
require statements
npm install the express module and then use a require statement to
load the module.
Step 2:
middleware
Middleware functions allow you to take action on any incoming
request and modify it before sending back a response.
Example:

Step 3:
executing common routines (routing)
Routes allow us to script specific actions based on the path. The
options are GET, POST, PUT and DELETE, but we will focus on
GET and POST for now.
Step 4:
ports
Your server has ports that are kind of like the address. Since
your server can handle many types of server-side scripts at
once, you need to tell it where each script should run.
So if you type:
https://localhost:3000/

into your browser, and you are running your Node app, the
server knows to run the specific script. In this case, as soon
as you enter the URL, you will log the message in the
console and be able to use any of your routes.
EXAMPLE

const express = require('express')


const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)`)
})
This app starts a server and listens on port 3000 for connections. The
app responds with “Hello World!” for requests to the root URL (/) or
route.
CONCLUSION

The express framework is the most common


framework used for developing Node.JS applications.
The express framework is built on top of the node.js
framework and helps in fast-tracking development of
server-based applications.
REFERENCE

1. MEAN.io. (2015) MEAN —Full-Stack JavaScript Using MongoDB,


Express, AngularJS, and Node.js. [Online]. Available: http://mean.io/
2. MEAN.io. (2015) MEAN —Full-Stack JavaScript Using MongoDB,
Express, AngularJS, and Node.js. [Online].Available: http://nodejs.org
3. MEAN.io. (2015) MEAN —Full-Stack JavaScript Using MongoDB,
Express, AngularJS, and Node.js. [Online].Available: http://expressjs.com/
4. S. Tilkov and S. Vinoski, “Node.js: Using JavaScript to Build High-
Performance Network Programs,”IEEE Internet Com-puting, vol. 14, no. 6,
pp. 80–83, 2010.
[Online].Available:http://doi.ieeecomputersociety.org/10.1109/MIC.2010.145
5. Bray, “The JavaScript Object Notation (JSON) Data Interchange Format
Interchange Format,” 2014. [Online].Available:
https://tools.ietf.org/html/rfc7159.
7. Knowledge Baseof Relational and NoSQL DatabaseManagement Systems.
[Online] Available:http://db-engines.com/en/rankin
8. https://nodejs.org/en/docs/ -NodeJs documentation. https://expressjs.com/-
ExpressJs documentation.
9. https://docs.mongodb.com/ -MongoDb documentation.
10. https://docs.angularjs.org/guide/concepts -Angular 1.x docs
11. http://adrianmejia.com/blog/2014/09/28/angularjs-tutorial-for-beginners-
with-nodejs-expressjs-and-mongodb/ -working with MEAN
12. http://www.ijcter.com/papers/volume-2/issue-5/ease-of-mean-stack-in-
web-development.pdf -LAMP and MEAN
THANK YOU
By:- Vaishnavi Umekar

You might also like