dadi / web

Web is a drop in front end for websites and web apps. Consumes data from DADI API and others
https://dadi.cloud/en/web/
Other
48 stars 16 forks source link

params not passed to middleware #408

Closed abovedave closed 3 years ago

abovedave commented 6 years ago

For a given middleware:

const Middleware = function (app) {
  app.use('/foo/:bar', (req, res, next, refresh) => {
    return res.end(req.params.bar)
  })
}

module.exports = function (app) {
  return new Middleware(app)
}

module.exports.Middleware = Middleware

When I visit the url /foo/helloworld, I expect helloworld to be accessible by using req.params.bar.

Instead I can see an empty params object in the req object.

  params: {},
  paths: [ '/verify/:token' ]
jimlambie commented 6 years ago

I think this might be because the middleware routes don't get added to the paths array in api/index.js, and indeed probably never go through controller/router.js where the params are bundled into the request