title: pass param in middleware expressjs/nodejs
body: <p>I am working in nodeJS project where I wanted to pass param in middleware so that I can validate in the code.</p>
  <p>E.g Middleware I created is as below</p>
  <pre><code>'use strict';
  // eslint-disable-next-line no-unused-vars
  import BadRequest from '../../../errors/BadRequest';
  // eslint-disable-next-line no-unused-vars
  import ResponseFormatter from '../../../util/ResponseFormatter';
  
  export default function middlewareWithParam (options) {
      return function (req, res, next) {
          // Implement the middleware function based on the options object
          
          return next();
          //ResponseFormatter.error(new BadRequest('03'), req, res);
      };
  }
  </code></pre>
  <p>Now I want use this middleware in the controller class so that by passing different values per end-point middle can validate the request.</p>
  <p>E.g.</p>
  <pre><code>Controller class
  
  import { middlewareWithParam } from '../middlewares/validators/Role/middlewareWithParam';
  
  export default class RoleController extends BaseController {
      paths = [
          {
              'method': 'GET', 'path': '/', 'middlewares': [middlewareWithParam({option1 : '1',option2 : '2'})], 'handler': this.getRoleList
          },
          {
              'method': 'GET', 'path': '/getRoleByID', 'middlewares': [middlewareWithParam({option1 : '3',option2 : '4'})], 'handler': this.getRoleByID
          }
  }
  </code></pre>
  <p>but I am getting error that</p>
  <pre><code>'middlewares': [(0, _middlewareWithParam.middlewareWithParam)()],
                                                                     ^
  
  TypeError: (0 , _middlewareWithParam.middlewareWithParam) is not a function
  </code></pre>