-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
🔨 Refactor apiRouter into smaller files #4350
base: master
Are you sure you want to change the base?
Conversation
c830ca6
to
dbe1aa1
Compare
Quick links (staging server):
Login:
SVG tester:Number of differences (default views): 0 ✅ Edited: 2024-12-20 15:43:57 UTC |
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! And I have additional suggestions.
This might be subjective, but since we are already doing the refactoring: I feel like we have too many layers of abstraction and I suggest we get rid of FunctionalRouter
.
I think the error handling it does is wrong — we should use an error handling middleware if we want to do anything custom (which should probably just be a Sentry integration).
And we can configure the same middleware that we do in the constructor either at the top app
level, or per each nested router.
req: Request, | ||
res: e.Response<any, Record<string, any>>, |
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.
Not specific to this route, just noticed it here. Why are we using Request
from our authentication
module, which is just — IMO — an unnecessary alias for express.Request
and Response
from Express, when we have our own Response
in the same authentication
module with additional properties? If anything it should be the other way around, right?
My preference would be to use Request
and Response
only from Express, if possible.
@rakyi good points! I'll give it a stab to clean this up as well. |
apiRouter.ts has become quite large and when you work with LLMs, large files are pretty annoying. This PR splits the route implementations into new files by topic.
The individual commits make it easier to follow along what happens and should hopefully also make review easier.