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

namespace Web.Api.Endpoints.Crypto;

internal sealed class CryptoMarkets : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/crypto/markets", async (
            ISender sender,
            CancellationToken ct
        ) =>
        {
            var response = await sender.Send(new Application.Features.Api.Crypto.Market.GetAll.Query(), ct);

            return ApiResponse.Ok(response.Markets);
        })
        .WithTags("Crypto")
        .AllowAnonymous();
    }
}