using FastEndpoints;

namespace SpaceGame.Api.Universe.Api;

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);
    }
}
