Code format

This commit is contained in:
2026-02-07 02:42:33 +01:00
parent 536e6392f0
commit 124fb62657
5 changed files with 8 additions and 33 deletions

View File

@@ -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. - 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. - 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 - 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: ## Tech constraints:
- .NET 10 - .NET 10

View File

@@ -1,5 +1,4 @@
using GameList.Data; using GameList.Data;
using GameList.Domain;
using GameList.Contracts; using GameList.Contracts;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using GameList.Infrastructure; using GameList.Infrastructure;
@@ -12,25 +11,13 @@ public static class AdminEndpoints
{ {
var admin = app.MapGroup("/api/admin").RequireAuthorization().AddEndpointFilter<AdminOnlyFilter>(); var admin = app.MapGroup("/api/admin").RequireAuthorization().AddEndpointFilter<AdminOnlyFilter>();
admin.MapPost("/results", async ([FromBody] ResultsOpenRequest request, AdminWorkflowService service) => admin.MapPost("/results", async ([FromBody] ResultsOpenRequest request, AdminWorkflowService service) => await service.SetResultsOpenAsync(request.ResultsOpen));
{
return await service.SetResultsOpenAsync(request.ResultsOpen);
});
admin.MapGet("/vote-status", async (AdminWorkflowService service) => admin.MapGet("/vote-status", async (AdminWorkflowService service) => await service.GetVoteStatusAsync());
{
return await service.GetVoteStatusAsync();
});
admin.MapPost("/joker", async ([FromBody] GrantJokerRequest request, AdminWorkflowService service) => admin.MapPost("/joker", async ([FromBody] GrantJokerRequest request, AdminWorkflowService service) => await service.GrantJokerAsync(request.PlayerId));
{
return await service.GrantJokerAsync(request.PlayerId);
});
admin.MapDelete("/players/{playerId:guid}", async (Guid playerId, AdminWorkflowService service) => admin.MapDelete("/players/{playerId:guid}", async (Guid playerId, AdminWorkflowService service) => await service.DeletePlayerAsync(playerId));
{
return await service.DeletePlayerAsync(playerId);
});
admin.MapPost("/link-suggestions", async ([FromBody] LinkSuggestionsRequest request, HttpContext ctx, AppDbContext db, AdminWorkflowService service) => 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); return await service.UnlinkSuggestionsAsync(player.Id, request.SuggestionId);
}); });
admin.MapPost("/reset", async (AdminWorkflowService service) => admin.MapPost("/reset", async (AdminWorkflowService service) => await service.ResetAsync());
{
return await service.ResetAsync();
});
admin.MapPost("/factory-reset", async (AdminWorkflowService service) => admin.MapPost("/factory-reset", async (AdminWorkflowService service) => await service.FactoryResetAsync());
{
return await service.FactoryResetAsync();
});
} }
} }

View File

@@ -10,7 +10,7 @@ internal static class AuthValidator
public static bool TryValidateRegistration(RegisterRequest request, out ValidatedRegistration validated, out string error) 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) if (string.IsNullOrWhiteSpace(username) || username.Length > MaxUsernameLength)
{ {
validated = default; 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) 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; normalizedUsername = string.Empty;
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(request.Password)) if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(request.Password))

View File

@@ -1,6 +1,5 @@
using GameList.Data; using GameList.Data;
using GameList.Domain; using GameList.Domain;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Security.Claims; using System.Security.Claims;

View File

@@ -99,14 +99,12 @@ public static class StateEndpoints
private static Phase NextPhase(Phase current) => current switch private static Phase NextPhase(Phase current) => current switch
{ {
Phase.Suggest => Phase.Vote, Phase.Suggest => Phase.Vote,
Phase.Vote => Phase.Results,
_ => Phase.Results _ => Phase.Results
}; };
private static Phase PrevPhase(Phase current) => current switch private static Phase PrevPhase(Phase current) => current switch
{ {
Phase.Results => Phase.Vote, Phase.Results => Phase.Vote,
Phase.Vote => Phase.Suggest,
_ => Phase.Suggest _ => Phase.Suggest
}; };
} }