using Application.Abstractions.Messaging;
using Web.Api.Common;

namespace Web.Api.Endpoints.News;

internal sealed class Sources : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/news/sources", async (
            ISender sender,
            CancellationToken ct
        ) =>
        {
            return ApiResponse.Ok(await sender.Send(new Application.Features.Api.News.GetSources.Query(), ct));
        })
        .WithTags("News")
        .AllowAnonymous();
    }
}