using BookHive.DTO.Member;
using BookHive.Repositories;
using FastEndpoints;

namespace BookHive.Endpoints.Members;

public class GetMembersEndpoint(MemberRepository memberRepository) : EndpointWithoutRequest<List<GetMemberDto>>
{
    public override void Configure()
    {
        Get("/members/");
        AllowAnonymous();
    }

    public override async Task HandleAsync(CancellationToken ct)
    {
        await Send.OkAsync(await memberRepository.ProjectToListAsync<GetMemberDto>(ct), ct);
    }
}