fix: GET /me auth guard now respects formatErrorResponse - #7
Merged
Conversation
/me was the only route still using the standalone authMiddleware() helper
as route middleware, which hardcodes { success, message } regardless of a
consumer's formatErrorResponse override. Inlined the same token/cookie
check the handler already had access to, so a missing or invalid token on
/me gets the same configured envelope as every other error in the router.
Caught while integrating a real consumer with a custom envelope - its
protected non-auth routes got the custom shape correctly, but /me's own
401 did not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /mewas the one route in the router still using the standaloneauthMiddleware()helper as route middleware, which hardcodes a{ success, message }error body regardless of a consumer'sformatErrorResponseoverride. Every other route (and the router's own catch-all error handler) already went through the configurablerespondError. Fixed by inlining the same cookie/bearer token check directly into the/mehandler.Found while integration-testing a real consumer with a custom envelope: its other protected routes got the custom shape correctly, but
/me's own 401 slipped through with the default shape.Test plan
/mereturns the customformatErrorResponseshapebun run build— cleanbun run test— 43/43 pass (33 core incl. the new test, 16 sqlite)bun run typecheck/bun run lint— clean