Simple Express.js Middleware

April 05, 2021

const express = require('express'),
      router = express.Router()

// Our middleware that logs request params when applied to a route
const logParams = (req, res, next) => console.log(req.params)  

// Our Route
router.get('/', logParams, (req, res) => {
  res.json({
    message: 'Logged Request Params'
  })
})