feat(backend): move endpoints to FastEndpoints handlers
This commit is contained in:
24
apps/backend/Handlers/GetWorldHealthHandler.cs
Normal file
24
apps/backend/Handlers/GetWorldHealthHandler.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using FastEndpoints;
|
||||
using SpaceGame.Simulation.Api.Simulation;
|
||||
|
||||
namespace SpaceGame.Simulation.Api.Handlers;
|
||||
|
||||
public sealed class GetWorldHealthHandler(WorldService worldService) : EndpointWithoutRequest
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/world/health");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override Task HandleAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var status = worldService.GetStatus();
|
||||
return SendOkAsync(new
|
||||
{
|
||||
ok = true,
|
||||
sequence = status.Sequence,
|
||||
generatedAtUtc = status.GeneratedAtUtc,
|
||||
}, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user