using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Widget;

/// <summary>크루 리더보드 (OBS 위젯용, 인증 불필요)</summary>
internal sealed class CrewRanking : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/widget/crew/ranking/{crewSessionID}", async (
            int crewSessionID,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.Crew.GetCrewRanking.Query(crewSessionID), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Widget")
        .AllowAnonymous();
    }
}