feat(vps): port better-auth route onto the Effect router (Step 2c)#146
Open
guidefari wants to merge 1 commit into
Open
feat(vps): port better-auth route onto the Effect router (Step 2c)#146guidefari wants to merge 1 commit into
guidefari wants to merge 1 commit into
Conversation
Step 2c of the Hono -> Effect HttpApi migration (docs/migration-effect-http-api.md). Isolates the one third-party routing integration so an auth regression is diagnosable to this one small diff, separate from the topology cutover in 2b. Why this exists: /auth/* now needs to be handled correctly before any authed route can be trusted on the new router. better-auth owns its own routing (auth.handler is opaque), so it can't become an HttpApiEndpoint -- it's mounted as its own wildcard route ahead of the Hono fallback, same basePath as before. - apps/vps/src/http/routes.ts: new betterAuthRoute wildcards /auth/* to auth.handler(prepareAuthRequest(...)), registered before honoFallback in the layer so it takes precedence. - apps/vps/src/routes/user/better-auth.routes.ts: exported prepareAuthRequest so it's reusable outside the Hono wrapper. - apps/vps/src/app.ts: removed the Hono /auth mount -- it's not used anywhere else (no other test or code path calls app.fetch directly since Step 2b made effectWebHandler the sole entry point). betterAuthMiddleware/attachSessionContext are unaffected; they call auth.api.getSession() directly, independent of the /auth HTTP route. Verified router precedence empirically rather than trusting the doc's claim: new tests hit /auth/get-session and /auth/does-not-exist through the live handler and confirm better-auth's own responses are returned, not the Hono fallback's 404. Full apps/vps suite: 142/142 passing (140 existing + 2 new), across 15 files.
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.
Why this exists: /auth/* has to work correctly on the new router before any authed route can be trusted on it. This isolates that one third-party routing integration into its own diff, separate from the topology cutover in #145 -- if auth breaks, it's this PR, not a tangle of unrelated changes.
Stacked on #145 (merge #142 -> #143 -> #144 -> #145 first).
Verification
/auth/get-sessionand/auth/does-not-existthrough the live handler and confirm better-auth's own responses come back, not the Hono fallback's 404 -- proves route precedence empirically rather than trusting the doc's claim about it.betterAuthMiddleware/attachSessionContext(used by other authed routes) are unaffected -- they callauth.api.getSession()directly, independent of the/authHTTP route.Next
Step 3a: port health handlers to
HttpApiBuilder.group, taking/health*over from the fallback -- first realHttpApigroup serving real traffic.