Commit 01873b8
authored
fix(event): remove all
* fix(event): remove all �ny casts, use typed authenticate and Prisma narrowing
- Replace 3×
equest.server as any / (app as any).authenticate preHandler boilerplate with �pp.authenticate — already declared on FastifyInstance in src/types/fastify.d.ts, consistent with follow.ts / team.ts pattern
- Replace 3× (request.user as any).id with
equest.user.id — covered by the FastifyJWT augmentation (user: { id: string; username: string })
- Replace 2× catch (error: any) with catch (error: unknown) + instanceof Prisma.PrismaClientKnownRequestError narrowing before .code access (P2002 join-duplicate → 409, P2025 leave-not-found → 404)
- Replace (error as Error).message with getErrorMessage(error) from the shared error utility already used in follow.ts / connect.ts
- Update event.test.ts: construct Prisma error mocks with
ew Prisma.PrismaClientKnownRequestError(...) so instanceof narrowing resolves correctly in tests; import Prisma alongside PrismaClient
* fixed
* fixed again
* fix: resolve lint issues in event routes and tests
---------
Signed-off-by: Srejoye Saha <sahasrejoye2005@gmail.com>any casts — typed authenticate, user.id, and Prisma error narrowing (#595)1 parent affea61 commit 01873b8
2 files changed
Lines changed: 214 additions & 211 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
367 | 366 | | |
368 | 367 | | |
369 | 368 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
458 | 459 | | |
459 | 460 | | |
460 | 461 | | |
| |||
488 | 489 | | |
489 | 490 | | |
490 | 491 | | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
| |||
0 commit comments