Skip to content

fix(vps): complete resolve HttpApi cutover (Step 6)#162

Merged
guidefari merged 2 commits into
migration/effect-http-apifrom
fix/6-resolve-cutover
Jul 11, 2026
Merged

fix(vps): complete resolve HttpApi cutover (Step 6)#162
guidefari merged 2 commits into
migration/effect-http-apifrom
fix/6-resolve-cutover

Conversation

@guidefari

Copy link
Copy Markdown
Owner

Why

resolve (step 6) was ported to HttpApiBuilder.group in #158, on branch
migration/6-resolve-group stacked on migration/6-profile-group. Both the
port and the old Hono file deletion happened correctly in that commit
(cad53ec9) -- but migration/6-profile-group's tip (with #158 already
stacked on it) never got merged forward into migration/effect-http-api.
The integration branch went straight from #157's merge to the step 6b docs
and client-swap commits instead, so #158 is absent from
migration/effect-http-api's history even though GitHub shows it as merged.

Net effect: apps/vps/src/app.ts kept mounting the old Hono
routes/resolve/* trio at /api/resolve, and packages/api/src/resolve.ts

  • apps/vps/src/http/resolve.handlers.ts never existed on this branch at
    all. Meanwhile feat(www): swap resolve consumer to typed Effect client (step 6b) #161 already swapped apps/www's useResolveSlug hook to
    call client.resolve.resolveSlug(...) against that same path -- it worked
    because the old Hono route was still live, not because the Effect port was
    serving it.

What to look for

Test evidence

No UI-visible behavior change (confirmed by grep: apps/www/src/lib/http.ts
already calls client.resolve.resolveSlug from #161, unchanged by this PR),
so no new screenshot -- the existing #158 evidence (show page rendering
bannerImageUrl/tags/hosts[].username) already covers this handler's
correctness; this PR only fixes routing.

bun run typecheck (vps): clean.

vitest run --config vitest.unit.config.ts (vps): the new
resolve (HttpApiBuilder group, Step 6) blackbox case fails with the same
pre-existing DB-connectivity error (500 instead of 404/200) affecting
7 other tests in this file on unmodified migration/effect-http-api
(health, music-artists, search, profile) -- verified by running the same
suite on origin/migration/effect-http-api before this change: identical
failure count and shape (Failed query errors from music_artists/audio
tables, i.e. the local testcontainers DB isn't reachable in this session).
Not introduced by this change; not fixed by this change either, since it's
an environment issue, not a code issue.

PR #158 ported resolve to HttpApiBuilder.group and correctly deleted the
old Hono trio on its own branch (migration/6-resolve-group, stacked on
migration/6-profile-group), but that branch never got merged forward
into migration/effect-http-api -- the integration branch moved directly
from #157's merge to the step 6b docs/client-swap commits. Result: the
old Hono resolve.routes.ts/.index.ts/.handlers.ts stayed on disk and
app.ts kept routing /api/resolve to them, while apps/www's resolve hook
(#161) already called the typed client -- pointed at a route that also
still worked, but via dead code shadowing the real port.

Cherry-picks cad53ec (the original port commit) onto the current tip:
wires ResolveHandlersLive into http/routes.ts, removes the /api/resolve
Hono mount from app.ts, deletes the superseded Hono files.
Comment thread apps/vps/src/http/resolve.handlers.ts Outdated
Comment on lines +8 to +16
const dieOnDatabaseError = <A, E, R>(effect: Effect.Effect<A, E | DatabaseErrorTag, R>) =>
effect.pipe(
Effect.tapErrorTag('DatabaseError', (cause) =>
Effect.logError('[resolve] database operation failed', cause)
),
Effect.catchTag('DatabaseError', (cause) => Effect.die(cause))
)

type DatabaseErrorTag = { readonly _tag: 'DatabaseError' }

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dieOnDatabaseError feels like a duplicate?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed: extracted to apps/vps/src/http/handler-utils.ts as a tag -> wrapper factory (dieOnDatabaseError(tag) => wrapper), so this file and search/music/profile handlers all share one definition instead of copy-pasting it. See 114ae54.

guidefari added a commit that referenced this pull request Jul 11, 2026
- Stacked PR merged into a feature branch that itself never merged
  forward into migration/effect-http-api (#158/resolve, fixed by #162).
- Adversarial review flagging a file as dead based on a same-package
  grep, missing a cross-package type-only import (#163/admin).
guidefari added a commit that referenced this pull request Jul 11, 2026
Review on #162 flagged dieOnDatabaseError as a likely duplicate --
correct: search, music, profile, and this PR's admin handlers each had
an identical copy differing only in the log-tag prefix string. Extracted
to apps/vps/src/http/handler-utils.ts as a tag -> wrapper factory, with
each handler file partially applying its own tag once at module scope
so call sites stay unchanged (dieOnDatabaseError(effect)).
Addresses review comment: dieOnDatabaseError was an identical
copy-paste across search/music/profile/resolve handlers, differing only
in the log-tag prefix string. Extracted to
apps/vps/src/http/handler-utils.ts as a tag -> wrapper factory; this PR
updates resolve.handlers.ts to use it. The other three handler files'
duplicate copies are updated on migration/6-admin-group (PR #163), which
also introduces the shared helper -- once both branches merge into
migration/effect-http-api, all four groups share one definition.
@guidefari guidefari merged commit fd359f6 into migration/effect-http-api Jul 11, 2026
2 checks passed
@guidefari guidefari deleted the fix/6-resolve-cutover branch July 11, 2026 16:11
guidefari added a commit that referenced this pull request Jul 11, 2026
- Stacked PR merged into a feature branch that itself never merged
  forward into migration/effect-http-api (#158/resolve, fixed by #162).
- Adversarial review flagging a file as dead based on a same-package
  grep, missing a cross-package type-only import (#163/admin).
guidefari added a commit that referenced this pull request Jul 11, 2026
Review on #162 flagged dieOnDatabaseError as a likely duplicate --
correct: search, music, profile, and this PR's admin handlers each had
an identical copy differing only in the log-tag prefix string. Extracted
to apps/vps/src/http/handler-utils.ts as a tag -> wrapper factory, with
each handler file partially applying its own tag once at module scope
so call sites stay unchanged (dieOnDatabaseError(effect)).
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