Skip to content

feat(vps): add unused Effect toWebHandler + Hono fallback (Step 2a)#144

Open
guidefari wants to merge 2 commits into
migration/1b-health-blackbox-testsfrom
migration/2a-toweb-handler-fallback
Open

feat(vps): add unused Effect toWebHandler + Hono fallback (Step 2a)#144
guidefari wants to merge 2 commits into
migration/1b-health-blackbox-testsfrom
migration/2a-toweb-handler-fallback

Conversation

@guidefari

@guidefari guidefari commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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

  • New 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.
  • Full existing suite still green (9/9 across the two blackbox files).
  • Typecheck, lint, format all clean.

Bonus: caught a bug in the migration doc itself

Verified HttpServerRequest.toWeb against 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant