From 02a12ee9e05efa0bcd9bf082eebd532413f9a860 Mon Sep 17 00:00:00 2001 From: Michilis Date: Sun, 23 Aug 2026 06:15:28 +0000 Subject: [PATCH] Fix the backend build against hono's narrowed route param type. npm audit fix floated hono from 4.4 to 4.11 within the ^4.4.7 range and tsc stopped compiling. c.req.param(key) has two overloads: it returns string only when the route path's literal type survives inference, and string | undefined otherwise. requireAuth() returns a handler annotated with a bare Context, which erases the path generic, so every param read behind it is now string | undefined. Only four sites failed. Everywhere else the value lands in eq((table as any).id, ...), where the any swallows it. Routes that also run zValidator kept their typing, since that middleware is generic and restores the inference -- door.ts:251 compiles while the two plain requireAuth routes beside it do not. loadEvent now accepts string | undefined and returns null for a missing id, which both door callers already handle with their 404 branch. The payments and tickets handlers pass the id off the row they just fetched and null-checked rather than the raw param. This leaves the underlying erasure in place. Typing requireAuth to preserve the path generic would restore string on every authed route, but it touches all of them and belongs in its own change. Co-Authored-By: Claude Opus 5 --- backend/src/routes/door.ts | 3 ++- backend/src/routes/payments.ts | 2 +- backend/src/routes/tickets.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/routes/door.ts b/backend/src/routes/door.ts index d856e0f..608e51c 100644 --- a/backend/src/routes/door.ts +++ b/backend/src/routes/door.ts @@ -84,7 +84,8 @@ function toDoorAttendee( }; } -async function loadEvent(eventId: string) { +async function loadEvent(eventId: string | undefined) { + if (!eventId) return null; const event = await dbGet( (db as any).select().from(events).where(eq((events as any).id, eventId)) ); diff --git a/backend/src/routes/payments.ts b/backend/src/routes/payments.ts index 72ad423..2544ad4 100644 --- a/backend/src/routes/payments.ts +++ b/backend/src/routes/payments.ts @@ -667,7 +667,7 @@ paymentsRouter.post('/:id/send-reminder', requireAuth(['admin', 'organizer']), a } try { - const result = await emailService.sendPaymentReminder(id); + const result = await emailService.sendPaymentReminder(payment.id); if (result.success) { const now = getNow(); diff --git a/backend/src/routes/tickets.ts b/backend/src/routes/tickets.ts index 3333b59..49f266c 100644 --- a/backend/src/routes/tickets.ts +++ b/backend/src/routes/tickets.ts @@ -1174,7 +1174,7 @@ ticketsRouter.post('/:id/mark-paid', requireAuth(['admin', 'organizer', 'staff'] // Send confirmation emails asynchronously (don't block the response) Promise.all([ - emailService.sendBookingConfirmation(id), + emailService.sendBookingConfirmation(ticket.id), payment ? emailService.sendPaymentReceipt(payment.id) : Promise.resolve(), ]).catch(err => { console.error('[Email] Failed to send confirmation emails:', err);