Simplified prom route when using default express route#113
Simplified prom route when using default express route#113kennsippell wants to merge 8 commits intoPayU:masterfrom
Conversation
|
|
||
| let app, config; | ||
|
|
||
| describe('when using express framework (default route)', function() { |
There was a problem hiding this comment.
I made a new test server in this PR because the default route (wildcard '*') assumes a paradigm where requests get handled by routes which don't call next().
In the existing tests, routes always call next() and the test logic relies on this for the error cases.
Open to ideas on how to better integrate this with existing tests.
| route = route ? route + req.route.path : req.route.path; | ||
| } | ||
|
|
||
| // #112 - aggregated express default route |
There was a problem hiding this comment.
There are three cases we need to worry about the default route.
- Routine route assignment (ln65)
- Appending when includeQueryParams is true (ln76)
- Nest.js case is actually setting route to
:0*(ln82)
Because this affected so many branches, I opted for a short-circuit. Alternatives and suggestions welcome.
There was a problem hiding this comment.
as it seems we're missing support * in general.
according to express documentation
This route path will match abcd, abxcd, abRANDOMcd, ab123cd, and so on.
app.get('/ab*cd', (req, res) => {
res.send('ab*cd')
})and also regex support, which we can ignore for now.
shouldn't we support all routes with * instead?
the main issue here is that we'd need to also support * with request params. i.e
app.get('/ab*cd/:id', (req, res) => {
res.send('ab*cd')
})this isn't a must for now, but would have been a more complete solution.
lmk what you think.
There was a problem hiding this comment.
I'd be interested to pursue the general solution. If somebody has an answer to this question, I'll have a better understanding of the requirements and can take a stab at it. Without that, I'm worried I'm going to break something.
I'll install Nest and play around if I don't heard back.
|
Before merge, let me test this on some production data and confirm this is really what we want & need :) I'll send an update on this shortly. |
|
Tested today and the data is much much cleaner. Also found #114. |
|
sorry for the very late response. is this still relevant? |
|
@kobik This is still relevant for our project. We are running in production with issues patched. Would be great to somehow get these into an official release. |
|
OK, let's drive this forward @kennsippell. After going over the discussion we had on the change, I'd like to be able to support Ofc I agree that the code shouldn't mutate the original request params, yet we need to make sure that we don't use the request params values for our metrics. |
|
Sorry for the year lull there. @kobik I've added three tests to confirm the expected behavior for the cases called out. Here case Does it seem to you like the |
|
I will mention that this case still fails (behavior same as in production today). If I use I don't understand what scenario this code is for. I believe it to be bugged. There are no tests for it. |
#112