Code format
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<AdminOnlyFilter>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using GameList.Data;
|
||||
using GameList.Domain;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user