refactor: strictly type return types in backend routes#698
refactor: strictly type return types in backend routes#698
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors backend routes to strictly type return types, specifically adding TypeScript type annotations to API endpoints. The changes introduce a new CommonBookingResponse type and apply it to the admin bookings PATCH route to improve type safety.
- Adds
CommonBookingResponsetype definition and schema - Replaces enum usage with string literal types for player levels
- Updates admin booking route to include explicit return type annotation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/shared/src/types/booking.ts | Exports new CommonBookingResponse type |
| packages/shared/src/schemas/booking.ts | Adds CommonBookingResponseSchema and replaces enum with string literals |
| apps/backend/src/app/api/admin/bookings/[id]/route.ts | Updates PATCH method with explicit return type annotation |
| user: z.union([z.string(), UserSchema]), | ||
| gameSession: z.union([z.string(), GameSessionSchema]), | ||
| playerLevel: z.nativeEnum(PlayLevel), | ||
| playerLevel: z.enum(["beginner", "intermediate", "advanced"]), |
There was a problem hiding this comment.
The hardcoded string literals for player levels replace the imported PlayLevel enum, which reduces type safety and maintainability. Consider keeping the enum import and using z.nativeEnum(PlayLevel) to maintain consistency with the type system.
Preview Deployment Status✅ Storybook Preview: https://68c9da4d.uabc-storybook.pages.dev ✅ Frontend Preview: https://3d9daf6a.uabc.pages.dev |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Description
WIP!
Fixes #580
Type of change
How Has This Been Tested?
Checklist before requesting a review