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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ed1d3a8c12
commit
02a12ee9e0
@@ -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<any>(
|
||||
(db as any).select().from(events).where(eq((events as any).id, eventId))
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user