Skip to content

[Refactor] Migrate API layer to Hono + Vercel Edge/Node adapter for long-term monorepo stability #934

Description

@hotlong

Background

Current monorepo Vercel deployment (see PR #933 and previous 404 diagnostics) relies on a [...path].ts API catch-all entrypoint and a Node.js serverless handler written in a way compatible with Vercel's conventions. However, due to monorepo structure, workspace dependencies, and Vercel's framework/SPA routing, serverless routing and bundling issues persist.

Motivation for Hono + Vercel Adapter Migration

  • Vercel now recommends using @hono/vercel (Edge or Node adapter) for TypeScript frameworks instead of manual catch-all entrypoints.
  • A single Hono app entrypoint, compatible with Vercel's adapter bootstrap system, is easier to test locally, more portable, and better aligned with both Edge Functions and monorepo dependency resolution with workspaces.
  • Code will be future-proofed for hybrid edge+node routes or incremental migration to Edge (when upstream deps are ready).
  • Avoids the routing ambiguity and bundling pitfalls of catch-all handlers with complex monorepo imports.

Acceptance Criteria

  • The API entrypoint is restructured into a proper Hono app (not a vestigial Next.js-style [...path].ts).
  • Hono is initialized directly at the top-level entry point for API (api/index.ts or similar), not as an exported handler.
  • The Hono app is exported and wired up via @hono/vercel Node adapter, e.g.:
    import{Hono}from'hono';import{handle}from'@hono/vercel';constapp=newHono();// ... route wiring ...exportdefaulthandle(app);
  • Internal kernel/plugin/registry initialization is guaranteed before the app handles any request; all service imports are compatible with esbuild/nft bundling.
  • Vercel routes are configured to anticipate Hono's routing (i.e. no catch-all raw handler, just native Node/Edge adapter bootstrap).
  • Monorepo dependencies imported by the app can be resolved without custom includeFiles hacks in vercel.json.
  • Add automated tests to ensure /api/v1/meta and /api/v1/packages return 200 OK after deployment.
  • All changes are reflected in CHANGELOG.md (or ROADMAP.md). Related issues updated on each progress.

Additional Notes

  • Hono's DX enables hybrid Edge+Node deployment model (future cloud scaling).
  • This unlocks easier local/testing/dev experience outside Vercel (e.g. with hono serve).
  • All API endpoints (including REST, GraphQL, metadata, and packages) should be exposed via Hono's router.
  • Kernel boot, broker wiring, and all async service initialization should be moved to top-level app.ts as needed. Async wiring must be non-blocking or use Hono's native async context patterns.

Related

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions