Skip to content

Conversation

Copy link

Copilot AI commented Aug 14, 2025

This PR implements the missing CRUD (Create, Read, Update, Delete) endpoints for the games API to support game submission and editing functionality. The design team needed these endpoints for UX development and acceptance testing.

New Endpoints Added

POST /api/games

Creates a new game with the following:

  • Required fields: title, description, publisher_id, category_id
  • Optional fields: star_rating
  • Returns: 201 with created game data
  • Validation: Ensures publisher and category references exist

PUT /api/games/

Updates an existing game with partial update support:

  • Accepts: Any combination of game fields
  • Returns: 200 with updated game data, 404 if game not found
  • Validation: Validates foreign key references when provided

DELETE /api/games/

Deletes a game:

  • Returns: 200 with success message, 404 if game not found
  • Effect: Permanently removes game from database

Error Handling

All endpoints include comprehensive error handling:

  • 400 Bad Request: Missing/invalid data, validation failures
  • 404 Not Found: Game, publisher, or category doesn't exist
  • 500 Server Error: Unexpected database/system errors
  • Database transaction rollback on errors

Testing

Added 12 comprehensive test cases covering:

  • Success scenarios for all CRUD operations
  • Error scenarios (missing data, invalid IDs, not found)
  • Input validation and edge cases
  • All 16 tests pass (4 existing + 12 new)

Implementation Details

  • Follows existing Flask blueprint patterns with proper type hints
  • Uses centralized get_games_base_query() for consistent data loading
  • Maintains existing JSON response structure with to_dict() method
  • Proper HTTP status codes and meaningful error messages

The API is now ready for the design team to begin UX development and testing!

Fixes #8.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: node /home/REDACTED/work/agents_tutorial1/agents_tutorial1/client/node_modules/.bin/astro dev --no-clearScreen (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 14, 2025 03:24
Co-authored-by: chikamsoachumsft <224665915+chikamsoachumsft@users.noreply.github.com>
Co-authored-by: chikamsoachumsft <224665915+chikamsoachumsft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add endpoints to create and edit games Add CRUD endpoints for games API Aug 14, 2025
Copilot AI requested a review from chikamsoachumsft August 14, 2025 03:28
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 endpoints to create and edit games

2 participants