Skip to content

Conversation

@br-Chan
Copy link
Contributor

@br-Chan br-Chan commented Aug 5, 2025

Description

WIP!

Fixes #580

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Manual testing (requires screenshots or videos)
  • Integration tests written (requires checks to pass)

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added thorough tests that prove my fix is effective and that my feature works
  • I've requested a review from another user

@br-Chan br-Chan requested a review from Copilot August 5, 2025 22:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CommonBookingResponse type 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"]),
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

Preview Deployment Status

✅ Storybook Preview: https://68c9da4d.uabc-storybook.pages.dev

✅ Frontend Preview: https://3d9daf6a.uabc.pages.dev

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 85.83% (🎯 70%)
🟰 ±0%
1659 / 1933
🟢 Statements 85.85% (🎯 70%)
🟰 ±0%
1705 / 1986
🟢 Functions 81.99% (🎯 80%)
🟰 ±0%
428 / 522
🟢 Branches 79.91% (🎯 60%)
🟰 ±0%
899 / 1125
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/backend/src/app/api/admin/bookings/[id]/route.ts 100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
Generated in workflow #2883 for commit 961d041 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BACKEND] Refactor backend routes to strictly type return type

2 participants