Express.js
Express.js
is fast, unopinionated, minimalist web framework for Node.js. We can for example process requests, do routes, etc…
Init npm, install Express.js and Nodemon
npm init
npm install --save express
npm install --save-dev nodemon
//then in package.json in "scripts" section
"start": "nodemon app.js"
app.js
const express = require('express');
const app = express();
//use new middleware function which will be executed for every new request
app.use((req, res, next) => {
console.log('in the middleware');
next(); //this will allow to go to another middleware
});
app.use((req, res, next) => {
console.log('in the another middleware');
res.send('<h1>Hello from Express !</h1>');
});
app.listen(3000);