Middlewares, making requests

const express = require(‘express’)
const server = express();

const m1 = function(req,res,next){
console.log(“We are in middleware 1”)
next()
}

const m2 = function(req,res,next){
console.log(“We are in middleware 2”)
res.send(“Hi Guys”);
}

const m3 = function(req,res,next){
console.log(“We are in middleware 3”)
res.send(“We have handled the request in middleware3”)
}

server.use(m1)

server.use(’/a’,m2)//Now this middleware is used only for the ‘/a’ path

server.get(’/’,function(req,res,next){
console.log(“We are in the get middlware which will call the next function to call it’s succedding middleware”)
next()
})
server.use(m3)
server.listen(3232)

//If i make a request on http://localhost:3232/a then output comes:
We are in middleware 1
We are in middleware 2
We are in middleware 1
We are in middleware 3

Rather than only:
We are in middleware 1
We are in middleware 2
//At the console