Middleware

function logOriginalUrl (req, res, next) {
  console.log('ReqURL:', req.originalUrl)
  next()
}
function logMethod (req, res, next) {
  console.log('Request Type:', req.method)
  next()
}
const log = [logOriginalUrl, logMethod]
app.get('/user/:id', log,
  (req, res, next)=>{
    res.send('User Info')
  }
)
Comments