You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some problems using the route.path parameter on propsToLog using nested routes with Express Router. Searching the internet I saw that this is an issue of the Express package itself.
Using express router with nested routes, for example:
// routes/users.jsconstusersRouter=Router({mergeParams: true});usersRouter.get('/:id',(request,response)=>{console.log(request.route.path)// "/:id" (instead of "/users/:id")returnresponse.status(200).json([/* list of users */])})// app.jsconstapp=express();app.use('/users',usersRoutes)
I would like to have a property on log that has the value /users/:id but, using route.path, I always get the value :id which can be mixed with any other route that has a /:id route, since they will log the same value. This ends up making it very difficult to filter the logs by route.
My suggestion: Can we create an own property of Escriba to handle this?
Using route.params we can create a value that uses the request.originalUrl and can create the same value as route.path does but full with parent paths/suffixes.
I'm having some problems using the
route.path
parameter onpropsToLog
using nested routes with Express Router. Searching the internet I saw that this is an issue of the Express package itself.See: expressjs/express#2879
Using express router with nested routes, for example:
I would like to have a property on log that has the value
/users/:id
but, usingroute.path
, I always get the value:id
which can be mixed with any other route that has a/:id
route, since they will log the same value. This ends up making it very difficult to filter the logs by route.My suggestion: Can we create an own property of Escriba to handle this?
Using
route.params
we can create a value that uses therequest.originalUrl
and can create the same value asroute.path
does but full with parent paths/suffixes.Example code (suggestion by @asheba):
The text was updated successfully, but these errors were encountered: