Migrate API layer from catch-all handler to Hono + Vercel adapter#935
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…el adapter - Create api/index.ts with top-level Hono app and handle(app) export - Remove api/[...path].ts (vestigial Next.js-style catch-all) - Rename getApp→ensureApp, export ensureKernel from _kernel.ts - Add /api/* → /api rewrite in vercel.json for native Hono routing - Remove path-normalisation workaround (no longer needed) - Add deployment smoke tests for /api/v1/meta and /api/v1/packages - Update CHANGELOG.md, studio CHANGELOG.md, deployment docs Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Refactor] Migrate API layer to Hono and Vercel Edge/Node adapter
Migrate API layer from catch-all handler to Hono + Vercel adapter
Mar 19, 2026
hotlong
marked this pull request as ready for review
March 19, 2026 03:05
hotlong
approved these changes
Mar 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates Studio’s Vercel serverless API entrypoint away from a file-based catch-all (api/[...path].ts) to the recommended Hono + Vercel adapter pattern (api/index.ts + rewrites), reducing routing ambiguity in monorepo deployments.
Changes:
- Replace the catch-all API function with
apps/studio/api/index.tsdelegating to the inner ObjectStack Hono app viainner.fetch(c.req.raw). - Rename and export kernel/app bootstrap helpers (
getApp→ensureApp,bootKernel→ensureKernel) and update docs accordingly. - Add
/api/(.*)→/apirewrite and expand adapter/deployment smoke tests for key endpoints.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/adapters/hono/src/hono.test.ts | Updates delegation-pattern tests and adds “deployment smoke tests” for /api/v1/meta + /api/v1/packages. |
| content/docs/guides/deployment-vercel.mdx | Updates Vercel deployment guide examples to api/index.ts + ensureApp/ensureKernel + new rewrites. |
| apps/studio/vercel.json | Adds /api/(.*) → /api rewrite before SPA fallback. |
| apps/studio/api/index.ts | Introduces new Hono Vercel entrypoint delegating all requests to the cached inner app. |
| apps/studio/api/_kernel.ts | Renames and exports ensureKernel() and ensureApp() for lazy cold-start boot. |
| apps/studio/api/[...path].ts | Removes old catch-all handler and its path-normalization workaround. |
| apps/studio/CHANGELOG.md | Documents the Studio-side entrypoint migration and associated changes. |
| CHANGELOG.md | Documents the repo-level migration and notes the previous fix is superseded. |
Comment on lines
+31
to
+36
| } catch (err: any) { | ||
| console.error('[Vercel] Handler error:', err?.message || err); | ||
| return c.json( | ||
| { success: false, error: { message: err?.message || 'Internal Server Error', code: 500 } }, | ||
| 500, | ||
| ); |
Comment on lines
+648
to
+650
| const innerApp = createHonoApp({ kernel: mockKernel, prefix: '/api/v1' }); | ||
| outerApp = new Hono(); | ||
| outerApp.all('*', async (c) => innerApp.fetch(c.req.raw)); |
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.
The
api/[...path].tscatch-all entrypoint causes routing ambiguity and requires path-normalization workarounds in monorepo Vercel deployments. Replace with Hono's native Vercel adapter pattern.Entrypoint
api/[...path].tswithapi/index.ts— a top-level Hono app exported viahandle(app)/api/(.*)→/api) handle sub-path routing; no more filename-based catch-allKernel bootstrap
getApp()→ensureApp(),bootKernel()→ensureKernel()(both exported)Vercel config
/api/(.*)→/apirewrite before the SPA fallback — eliminates path normalization logic that was in the old catch-allTests
GET /api/v1/metaandGET /api/v1/packagesreturn 200 through outer→inner delegationapi/index.tspattern (46 tests, all passing)Docs
deployment-vercel.mdxcode examples and checklistCHANGELOG.mdOriginal prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.