Summary
Remove the unsafe (app as any).authenticate fallback chains still present in cards.ts, event.ts, nfc.ts, and connect.ts, and replace them with the typed app.authenticate decorator — same pattern just applied to team.ts in #581 (closes #554).
Contexts
In #581, team.ts was refactored to remove all any usages and replace the manual auth fallback chain with a properly typed app.authenticate decorator (typed via the @fastify/jwt + Fastify augmentation in src/types/fastify.d.ts).
The same unsafe pattern still exists in several other route files:
if (typeof (app as any).authenticate === 'function') {
await (app as any).authenticate(request, reply);
return;
}
and in a few places, an additional request.server as any fallback layered on top. This was flagged as a follow-up during review on #581 so the cleanup can go repo-wide instead of being one-off.
Tasks
Acceptance Criteria
Area
backend
Difficulty
Easy / Good first issue — pattern is already established and proven in #581, mostly mechanical repetition across 4 files.
Summary
Remove the unsafe
(app as any).authenticatefallback chains still present incards.ts,event.ts,nfc.ts, andconnect.ts, and replace them with the typedapp.authenticatedecorator — same pattern just applied toteam.tsin #581 (closes #554).Contexts
In #581,
team.tswas refactored to remove allanyusages and replace the manual auth fallback chain with a properly typedapp.authenticatedecorator (typed via the@fastify/jwt+ Fastify augmentation insrc/types/fastify.d.ts).The same unsafe pattern still exists in several other route files:
and in a few places, an additional
request.server as anyfallback layered on top. This was flagged as a follow-up during review on #581 so the cleanup can go repo-wide instead of being one-off.Tasks
(app as any).authenticate/request.server as anyfallback chains withpreHandler: [app.authenticate]insrc/routes/cards.tssrc/routes/event.tssrc/routes/nfc.tssrc/routes/connect.tsrequest.jwtVerify()try/catch in each preHandler (the decorator already handles 401 on failure)app.authenticateis decorated insidebuildApp()beforeapp.register(...)(Fastify resolvespreHandlerduringapp.ready())Acceptance Criteria
(app as any)orrequest.server as anyremains in the 4 files abovepreHandler: [app.authenticate]consistently, no.bind(app)neededtsc --noEmitpasses with 0 errorsArea
backendDifficulty
Easy/Good first issue— pattern is already established and proven in #581, mostly mechanical repetition across 4 files.