namespace Backend.Endpoints;

public static partial class PublicEndpoints
{
    public static IEndpointRouteBuilder MapPublicEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/api/public");

        group.MapGet("/overview", GetOverview)
            .WithName("GetOverview")
            .WithOpenApi();

        group.MapGet("/site-status", GetSiteStatus)
            .WithName("GetSiteStatus")
            .WithOpenApi();

        group.MapGet("/host-image", GetHostImage)
            .WithName("GetPublicHostImage")
            .WithOpenApi();

        group.MapGet("/seasons/{year:int}/categories", GetSeasonCategories)
            .WithName("GetSeasonCategories")
            .WithOpenApi();

        group.MapGet("/seasons/{year:int}/winners", GetWinnerArchive)
            .WithName("GetWinnerArchive")
            .WithOpenApi();

        group.MapGet("/seasons/{year:int}/sponsors", GetSponsors)
            .WithName("GetPublicSponsors")
            .WithOpenApi();

        group.MapGet("/seasons/{year:int}/me", GetUserParticipation)
            .WithName("GetUserParticipation")
            .WithOpenApi();

        group.MapPost("/nominations", CreateNomination)
            .RequireRateLimiting(Backend.Common.ApplicationDefaults.PublicWriteRateLimitPolicy)
            .WithName("CreateNomination")
            .WithOpenApi();

        group.MapPost("/votes", CreateVote)
            .RequireRateLimiting(Backend.Common.ApplicationDefaults.PublicWriteRateLimitPolicy)
            .WithName("CreateVote")
            .WithOpenApi();

        group.MapPost("/clips", CreateClip)
            .RequireRateLimiting(Backend.Common.ApplicationDefaults.PublicWriteRateLimitPolicy)
            .WithName("CreateClip")
            .WithOpenApi();

        group.MapPost("/showacts", CreateShowactApplication)
            .RequireRateLimiting(Backend.Common.ApplicationDefaults.PublicWriteRateLimitPolicy)
            .WithName("CreateShowactApplication")
            .WithOpenApi();

        return app;
    }
}
