-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add logging of web-config-server requests to the api_request_log table #4049
Conversation
@@ -62,6 +60,7 @@ export async function createApp() { | |||
|
|||
// API router | |||
app.use('/api/v1', getRoutesForApiV1()); | |||
app.use('/api/v1', logApiRequest(modelRegistry, 'tupaia', 1)); |
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.
Strictly speaking I suppose this should be called web-config
rather than tupaia
. However, I think that in an ideal world this server would be called tupaia-server
, and I wouldn't mind kickstarting that transition. Also, since non-devs may be viewing these logs, having a user friendly name seems apt. Happy to hear reviewer's thoughts though 👍
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.
lgtm, just wonder if we need to repeat that util code
* Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
export const logApiRequest = (models, apiName, version) => async (req, res, next) => { |
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.
Would the util exported from server-boilerplate
work here instead?
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.
Technically the way the userId
is determined is different. However if I'm being honest I was a bit worried about creating a dependency on server-boilerplate. Now that I check, there's already a dependency there! 🤦
I thiiiink it's might still be cleaner to do it separate rather than try and make the userId
logic more generic... hopefully we switch this bad boy over to server-boilerplate sometime in the not too distant future and then we can scrap this?
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.
Sweet sounds good - so long as you'd considered it!
Issue https://beyondessential.slack.com/archives/C02HES8HFQF/p1658966488670609:
Just added logging of api requests to the web-config-server app.