middleware meaning code example

Example 1: middleware uses

const methodOverride = require('method-override');
const { url } = require("inspector");
server.use(methodOverride('_method'));


// middleware
server.use(express.static("./public"));
server.set("view engine", "ejs");
server.use(express.urlencoded({ extended: true }));

Example 2: middleware

//just for me lol... pls don't delete
"middleware" - code that runs before the final route call back.
They are in the middle of the beginning of the route and the 
callback function.

Example 3: middleware

app.use("/", (req, res, next) => {
  console.log("I am a middleaware")
  next()
})

Example 4: middleware

, PostController::class)->middleware('auth:api');