Refactor/clean up game application service#257
Conversation
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net |
…ace with the explicit status endpoints
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net |
There was a problem hiding this comment.
Pull request overview
Refactors the Sudoku game API/controller layer to use MediatR commands/queries directly (removing the IGameApplicationService abstraction), introduces explicit game status/action endpoints, and adjusts clients/tests/configuration around Cosmos DB and App Configuration.
Changes:
- Replace
IGameApplicationServiceusage with directIMediator.Send(...)in API controllers; remove the application service layer. - Introduce explicit game status/action endpoints (pause/resume/abandon/complete, actions controller), updating React/Blazor clients and tests.
- Simplify Cosmos DB/App Configuration setup (incl. optional App Configuration enablement and container auto-create options).
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/Sudoku.React/src/pages/GamePage.tsx | Switches status updates to pauseGame/resumeGame calls. |
| src/frontend/Sudoku.React/src/pages/GamePage.test.tsx | Updates mocks/assertions for pause/resume status calls. |
| src/frontend/Sudoku.React/src/pages/GamePage.integration.test.tsx | Updates integration mocks for pause/resume status calls. |
| src/frontend/Sudoku.React/src/hooks/useGameService.ts | Replaces generic status update with pauseGame/resumeGame helpers. |
| src/frontend/Sudoku.React/src/api/apiClient.ts | Adds pauseGame/resumeGame endpoints (POST). |
| src/frontend/Sudoku.React/src/api/apiClient.test.ts | Adds/updates tests for pause/resume API calls. |
| src/frontend/Sudoku.Blazor/appsettings.json | Moves appconfig endpoint settings into base config. |
| src/frontend/Sudoku.Blazor/appsettings.Development.json | Removes dev-specific appconfig block. |
| src/frontend/Sudoku.Blazor/Services/HttpClients/IGameApiClient.cs | Replaces SaveGameStatusAsync with explicit status action methods. |
| src/frontend/Sudoku.Blazor/Services/HttpClients/GameApiClient.cs | Implements explicit status actions via POST; create-game now follows Location to fetch full game. |
| src/frontend/Sudoku.Blazor/Services/GameStateManager.cs | Maps local GameStatus values to explicit status action calls. |
| src/frontend/Sudoku.Blazor/Program.cs | Only requires Key Vault outside Development. |
| src/backend/Tests/Mocks/MockGameApiClientExtensions.cs | Updates verification to match explicit status action methods. |
| src/backend/Tests/Application/Services/GameApplicationServiceTests.cs | Removes tests for deleted GameApplicationService. |
| src/backend/Tests/Application/Handlers/CreateGameCommandHandlerTests.cs | Updates handler abstraction and asserts returned game id. |
| src/backend/Tests/API/PossibleValuesControllerTests.cs | Switches controller tests to Mediator commands/queries. |
| src/backend/Tests/API/GamesControllerTests.cs | Updates tests for Mediator usage and create-game response semantics. |
| src/backend/Tests/API/GameStatusControllerTests.cs | Expands tests for explicit status endpoints using Mediator. |
| src/backend/Tests/API/GameActionsControllerTests.cs | Updates tests to send MediatR commands. |
| src/backend/Tests/API/DependencyInjectionTests.cs | Updates DI expectations (Mediator instead of app service) and required services list. |
| src/backend/Tests/API/BaseGameControllerTests.cs | Base controller tests now mock IMediator. |
| src/backend/Sudoku.ServiceDefaults/AzureAppConfigurationExtensions.cs | Adds AzureAppConfiguration:Enabled flag to skip App Configuration bootstrap. |
| src/backend/Sudoku.Infrastructure/Services/CosmosDbService.cs | Adds optional auto-create for DB/container (with partition key path). |
| src/backend/Sudoku.Infrastructure/Repositories/CosmosDbUserProfileRepository.cs | Adds optional auto-create for profiles container. |
| src/backend/Sudoku.Infrastructure/Configuration/InfrastructureServiceCollectionExtensions.cs | Removes inline CosmosClient construction; relies on external registration. |
| src/backend/Sudoku.Infrastructure/Configuration/CosmosDbOptions.cs | Adds AutoCreateContainers and ContainerPartitionKeyPath options (defaults preserved). |
| src/backend/Sudoku.Application/Services/GameApplicationService.cs | Deletes application service layer. |
| src/backend/Sudoku.Application/Interfaces/IGameApplicationService.cs | Deletes application service interface. |
| src/backend/Sudoku.Application/Handlers/CreateGameCommandHandler.cs | Create-game now returns a Result<string> game id. |
| src/backend/Sudoku.Application/Configuration/ApplicationServiceCollectionExtensions.cs | Stops registering removed application service; keeps MediatR registration. |
| src/backend/Sudoku.Application/Commands/CreateGameCommand.cs | Updates command to ICommand<string>. |
| src/backend/Sudoku.AppHost/appsettings.json | Sets CosmosDb connection string in base config. |
| src/backend/Sudoku.AppHost/appsettings.Development.json | Removes duplicated connection string section. |
| src/backend/Sudoku.AppHost/Program.cs | Removes Key Vault reference wiring; keeps Cosmos emulator reference. |
| src/backend/Sudoku.Api/appsettings.json | Removes explicit CosmosDb DB/container name block (defaults apply). |
| src/backend/Sudoku.Api/appsettings.Development.json | Adjusts CosmosDb dev settings and enables auto-create. |
| src/backend/Sudoku.Api/Program.cs | Adds user secrets; gates Key Vault to non-Development; registers Cosmos client when enabled. |
| src/backend/Sudoku.Api/Controllers/PossibleValuesController.cs | Uses Mediator commands instead of app service. |
| src/backend/Sudoku.Api/Controllers/GamesController.cs | Uses Mediator; create-game now returns 201 with Location only. |
| src/backend/Sudoku.Api/Controllers/GameStatusController.cs | Replaces PATCH status with explicit POST endpoints (pause/resume/abandon/complete/validate). |
| src/backend/Sudoku.Api/Controllers/GameActionsController.cs | Uses Mediator for move/reset/undo commands. |
| src/backend/Sudoku.Api/Controllers/BaseGameController.cs | Base controller now depends on IMediator; HandleUnitResult uses Result. |
| scripts/set-app-config.sh | Updates App Config keys for CosmosDb auto-create/SSL validation options. |
| Tests/E2E/fixtures/api-mocks.ts | Updates E2E route mocking for status POST endpoints and validate response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net |
Description
Cleans up CosmosDb configuration and refactored game controller code.
Type of Change
Changes Made
Testing
Screenshots (if applicable)
Checklist