Skip to content

Commit ebadf1e

Browse files
Copilothotlong
andcommitted
refactor: extract uiHandler for consistency, add UI base path test
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 404c906 commit ebadf1e

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

packages/adapters/hono/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @objectstack/hono
22

3+
## 3.2.8
4+
5+
### Patch Changes
6+
7+
- fix: register all standard API routes in `createHonoApp()` — resolves 404 errors for `/api/v1/packages`, `/api/v1/analytics`, `/api/v1/automation`, `/api/v1/i18n`, and `/api/v1/ui` routes after Vercel deployment
8+
- fix: forward query parameters to `handleMetadata()` so package filtering and locale queries work correctly
9+
- Added comprehensive tests for all newly registered route handlers
10+
311
## 3.2.7
412

513
### Patch Changes

packages/adapters/hono/src/hono.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,16 @@ describe('createHonoApp', () => {
562562
);
563563
});
564564

565+
it('GET /api/ui calls handleUi with empty sub-path', async () => {
566+
const res = await app.request('/api/ui');
567+
expect(res.status).toBe(200);
568+
expect(mockDispatcher.handleUi).toHaveBeenCalledWith(
569+
'',
570+
expect.any(Object),
571+
expect.objectContaining({ request: expect.anything() }),
572+
);
573+
});
574+
565575
it('GET /api/ui/view/account?type=list forwards query params', async () => {
566576
const res = await app.request('/api/ui/view/account?type=list');
567577
expect(res.status).toBe(200);

packages/adapters/hono/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export function createHonoApp(options: ObjectStackHonoOptions): Hono {
283283
app.all(`${prefix}/i18n`, i18nHandler);
284284

285285
// --- UI ---
286-
app.all(`${prefix}/ui/*`, async (c) => {
286+
const uiHandler = async (c: any) => {
287287
try {
288288
const subPath = c.req.path.substring(`${prefix}/ui`.length);
289289

@@ -296,7 +296,9 @@ export function createHonoApp(options: ObjectStackHonoOptions): Hono {
296296
} catch (err: any) {
297297
return errorJson(c, err.message || 'Internal Server Error', err.statusCode || 500);
298298
}
299-
});
299+
};
300+
app.all(`${prefix}/ui/*`, uiHandler);
301+
app.all(`${prefix}/ui`, uiHandler);
300302

301303
return app;
302304
}

0 commit comments

Comments
 (0)