diff --git a/AGENTS.md b/AGENTS.md index fcd9f8d..6932b70 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,9 +13,6 @@ Also see the other related files: API.md, IIS.md, SPEC.md - If you find unexpected changes in the code (deletions, changes, diff results that were not communicated.), never revert them and never restore the old state. Assume that those changes happened with intent. - After changing the backend, feel free run "dotnet build" and "dotnet ef database update". If this is blocked by a running dotnet process, feel free to kill the process and retry the operations once. - Keep changes small and testable -- Avoid introducing new dependencies unless they remove complexity. -- Keep endpoint logic in `Endpoints/` and shared helpers/DTOs in their folders to avoid Program.cs bloat. -- Keep css and js files diversified to avoid styles.css or app.js bloat. ## Tech constraints: - .NET 10 diff --git a/Endpoints/AdminEndpoints.cs b/Endpoints/AdminEndpoints.cs index 2e01362..d19fb77 100644 --- a/Endpoints/AdminEndpoints.cs +++ b/Endpoints/AdminEndpoints.cs @@ -1,5 +1,4 @@ using GameList.Data; -using GameList.Domain; using GameList.Contracts; using Microsoft.AspNetCore.Mvc; using GameList.Infrastructure; @@ -12,25 +11,13 @@ public static class AdminEndpoints { var admin = app.MapGroup("/api/admin").RequireAuthorization().AddEndpointFilter(); - admin.MapPost("/results", async ([FromBody] ResultsOpenRequest request, AdminWorkflowService service) => - { - return await service.SetResultsOpenAsync(request.ResultsOpen); - }); + admin.MapPost("/results", async ([FromBody] ResultsOpenRequest request, AdminWorkflowService service) => await service.SetResultsOpenAsync(request.ResultsOpen)); - admin.MapGet("/vote-status", async (AdminWorkflowService service) => - { - return await service.GetVoteStatusAsync(); - }); + admin.MapGet("/vote-status", async (AdminWorkflowService service) => await service.GetVoteStatusAsync()); - admin.MapPost("/joker", async ([FromBody] GrantJokerRequest request, AdminWorkflowService service) => - { - return await service.GrantJokerAsync(request.PlayerId); - }); + admin.MapPost("/joker", async ([FromBody] GrantJokerRequest request, AdminWorkflowService service) => await service.GrantJokerAsync(request.PlayerId)); - admin.MapDelete("/players/{playerId:guid}", async (Guid playerId, AdminWorkflowService service) => - { - return await service.DeletePlayerAsync(playerId); - }); + admin.MapDelete("/players/{playerId:guid}", async (Guid playerId, AdminWorkflowService service) => await service.DeletePlayerAsync(playerId)); admin.MapPost("/link-suggestions", async ([FromBody] LinkSuggestionsRequest request, HttpContext ctx, AppDbContext db, AdminWorkflowService service) => { @@ -50,15 +37,9 @@ public static class AdminEndpoints return await service.UnlinkSuggestionsAsync(player.Id, request.SuggestionId); }); - admin.MapPost("/reset", async (AdminWorkflowService service) => - { - return await service.ResetAsync(); - }); + admin.MapPost("/reset", async (AdminWorkflowService service) => await service.ResetAsync()); - admin.MapPost("/factory-reset", async (AdminWorkflowService service) => - { - return await service.FactoryResetAsync(); - }); + admin.MapPost("/factory-reset", async (AdminWorkflowService service) => await service.FactoryResetAsync()); } } diff --git a/Endpoints/AuthValidator.cs b/Endpoints/AuthValidator.cs index 854614f..dd783f6 100644 --- a/Endpoints/AuthValidator.cs +++ b/Endpoints/AuthValidator.cs @@ -10,7 +10,7 @@ internal static class AuthValidator public static bool TryValidateRegistration(RegisterRequest request, out ValidatedRegistration validated, out string error) { - var username = (request.Username ?? string.Empty).Trim(); + var username = (request.Username).Trim(); if (string.IsNullOrWhiteSpace(username) || username.Length > MaxUsernameLength) { validated = default; @@ -48,7 +48,7 @@ internal static class AuthValidator public static bool TryValidateLogin(LoginRequest request, out string username, out string normalizedUsername, out string error) { - username = (request.Username ?? string.Empty).Trim(); + username = (request.Username).Trim(); normalizedUsername = string.Empty; if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(request.Password)) diff --git a/Endpoints/EndpointHelpers.cs b/Endpoints/EndpointHelpers.cs index 20d5226..b55cbeb 100644 --- a/Endpoints/EndpointHelpers.cs +++ b/Endpoints/EndpointHelpers.cs @@ -1,6 +1,5 @@ using GameList.Data; using GameList.Domain; -using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Security.Claims; diff --git a/Endpoints/StateEndpoints.cs b/Endpoints/StateEndpoints.cs index 48f21cc..1f91b47 100644 --- a/Endpoints/StateEndpoints.cs +++ b/Endpoints/StateEndpoints.cs @@ -99,14 +99,12 @@ public static class StateEndpoints private static Phase NextPhase(Phase current) => current switch { Phase.Suggest => Phase.Vote, - Phase.Vote => Phase.Results, _ => Phase.Results }; private static Phase PrevPhase(Phase current) => current switch { Phase.Results => Phase.Vote, - Phase.Vote => Phase.Suggest, _ => Phase.Suggest }; }