From b24915783d2fd02c9bf6d24d56a7df65f8b69bb4 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Tue, 24 Feb 2026 15:37:24 +0100 Subject: [PATCH] fix build --- ka-note/VERSION | 2 +- ka-note/server/src/lib/route-utils.ts | 13 +++++++------ ka-note/server/src/routes/push.ts | 11 +++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ka-note/VERSION b/ka-note/VERSION index 8f6d691..d7158c7 100644 --- a/ka-note/VERSION +++ b/ka-note/VERSION @@ -1 +1 @@ -1.1.47 \ No newline at end of file +1.1.49 \ No newline at end of file diff --git a/ka-note/server/src/lib/route-utils.ts b/ka-note/server/src/lib/route-utils.ts index ceee270..5a0c8e7 100644 --- a/ka-note/server/src/lib/route-utils.ts +++ b/ka-note/server/src/lib/route-utils.ts @@ -1,13 +1,14 @@ -import type { Context, Env } from 'hono'; +import type { Context } from 'hono'; -type Handler = (c: Context) => Promise; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type AnyHandler = (c: Context) => Promise; /** * Wraps a route handler with structured error logging. - * Logs the route label, error message and stack, then returns 500. + * Preserves the handler's generic type so Hono can infer env/input/output types correctly. */ -export function handle(label: string, fn: Handler): Handler { - return async (c: Context) => { +export function handle(label: string, fn: F): F { + return (async (c: Context) => { try { return await fn(c); } catch (err) { @@ -16,5 +17,5 @@ export function handle(label: string, fn: Handler): Handler console.error(`[${label}]`, c.req.method, c.req.path, msg, stack); return c.json({ error: 'internal server error', detail: msg }, 500); } - }; + }) as F; } diff --git a/ka-note/server/src/routes/push.ts b/ka-note/server/src/routes/push.ts index aa35f47..f9c7c15 100644 --- a/ka-note/server/src/routes/push.ts +++ b/ka-note/server/src/routes/push.ts @@ -89,7 +89,8 @@ const pushDailyLogRoute = createRoute({ const push = new OpenAPIHono(); -push.openapi(pushDailyLogRoute, handle('push/daily-log', async (c) => { +push.openapi(pushDailyLogRoute, async (c) => { + try { const { userId } = c.get('auth'); const lock = await isLocked(userId); @@ -143,6 +144,12 @@ push.openapi(pushDailyLogRoute, handle('push/daily-log', async (c) => { }); return c.json({ contextId: 'daily-log', topicId: JOURNAL_TOPIC_ID, historyEntryId: id }, 201); -})); + } catch (err) { + const msg = err instanceof Error ? err.message : String(err); + console.error('[push/daily-log]', msg); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return c.json({ error: 'internal server error', detail: msg }, 500) as any; + } +}); export default push;