feat(vps): add unused Effect toWebHandler + Hono fallback (Step 2a)#144
Open
guidefari wants to merge 2 commits into
Open
feat(vps): add unused Effect toWebHandler + Hono fallback (Step 2a)#144guidefari wants to merge 2 commits into
guidefari wants to merge 2 commits into
Conversation
Step 2a of the Hono -> Effect HttpApi migration (docs/migration-effect-http-api.md). Nothing in prod changes: the new handler is exported but not wired to Bun.serve. - apps/vps/src/http/routes.ts: honoFallback wildcards every request to the existing Hono app's fetch unchanged. createWebHandler wraps it with HttpRouter.toWebHandler + HttpServer.layerServices. - apps/vps/src/index.ts: builds and exports effectWebHandler alongside the existing Bun.serve export. The entry point still serves via the old Hono path. Note: the migration doc's Phase 5 sketch calls HttpServerRequest.toWeb(request) as a plain sync conversion, but the real signature returns Effect.Effect<Request, RequestError> -- it must be yielded inside the Effect.gen, not called bare. Caught by typechecking against the installed effect@4.0.0-beta.93 types rather than the doc's snippet. routes.blackbox.test.ts: reuses the @gbfm/api schemas from step 1b to assert the new handler behaves identically to the Hono app for health, a real API route (music/artists), and an unknown route (404) -- 4/4 passing against a live Postgres testcontainer.
Discovered while implementing step 2a: HttpServerRequest.toWeb returns Effect.Effect<Request, RequestError>, not a plain Request. Update the better-auth and Hono-fallback snippets to yield* it inside Effect.gen, matching apps/vps/src/http/routes.ts.
This was referenced Jul 10, 2026
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: the migration's biggest risk is the serving-stack cutover (Hono's Bun.serve -> Effect's HttpRouter). This PR de-risks that swap before it touches prod -- it builds the new handler and proves it behaves identically to the current app, without flipping the switch. If something were wrong with the handler/fallback plumbing, we find out here, not in a deploy.
Stacked on #143 (merge #142 -> #143 first).
Verification
routes.blackbox.test.ts: the new handler behaves identically to the plain Hono app for health, a real API route, and an unknown route -- 4/4 passing against a live Postgres testcontainer.Bonus: caught a bug in the migration doc itself
Verified
HttpServerRequest.toWebagainst the installed effect types -- the doc's sketch treated it as sync, it's actually effectful. Fixed the doc so later steps don't copy the mistake.Next
Step 2b flips the switch: swap the deploy entry point to this handler for real.