-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified prom route when using default express route #113
base: master
Are you sure you want to change the base?
Conversation
|
||
let app, config; | ||
|
||
describe('when using express framework (default route)', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -57,6 +57,11 @@ class ExpressMiddleware { | |||
route = route ? route + req.route.path : req.route.path; | |||
} | |||
|
|||
// #112 - aggregated express default route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
#112