Skip to content

Add tournament status and mode filters to GET /api/tournaments#345

Open
Stanley-Owoh wants to merge 15 commits into
TevaLabs:mainfrom
Stanley-Owoh:add-tournament-status-and-mode-filters-to-get-api-tournaments-330
Open

Add tournament status and mode filters to GET /api/tournaments#345
Stanley-Owoh wants to merge 15 commits into
TevaLabs:mainfrom
Stanley-Owoh:add-tournament-status-and-mode-filters-to-get-api-tournaments-330

Conversation

@Stanley-Owoh

Copy link
Copy Markdown
Contributor

Summary

Add status and mode query param filters to GET /api/tournaments so the frontend can render tournament tabs without client-side filtering.

Changes

src/schemas/tournament.schema.ts

  • Added tournamentListQuerySchema — extends the existing offsetPaginationSchema with two optional enum fields:
    • status: UPCOMING | ACTIVE | COMPLETED
    • mode: UP_DOWN | LEGENDS
  • Exported TournamentListQuery type

src/routes/tournaments.routes.ts

  • Replaced validate(offsetPaginationSchema, "query") with validate(tournamentListQuerySchema, "query") on the list endpoint
  • Updated the request handler to destructure status and mode from the validated query
  • Filters are applied independently and combined — invalid enum values return a 400 via the existing validate middleware
  • Removed the old inline toUpperCase() case-insensitive status filter (validation is now strict through Zod)

README.md

  • Documented the two new optional query params with curl examples

Acceptance Criteria

  • ?status=ACTIVE returns only active tournaments
  • ?mode=LEGENDS returns only legends-mode tournaments
  • ?status=UPCOMING&mode=LEGENDS combines both filters
  • ?status=INVALID returns 400
  • No filters returns all tournaments (backward compatible)

Closes #330

- Add tournamentListQuerySchema with status and mode enum validation
- Apply Zod-validated query params to filter mock data server-side
- Document query params in README with curl examples
…-and-mode-filters-to-get-api-tournaments-330
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.

Add tournament status and mode filters to GET /api/tournaments

1 participant