All.cs 705 B

123456789101112131415161718192021222324252627
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. namespace Web.Api.Endpoints.Feed;
  4. internal sealed class All : IEndpoint
  5. {
  6. public void MapEndpoint(IEndpointRouteBuilder app)
  7. {
  8. app.MapGet("api/feed/all", async (
  9. int? page,
  10. int? perPage,
  11. ISender sender,
  12. CancellationToken ct
  13. ) => {
  14. var query = new Application.Features.Api.Feed.GetAll.Query(
  15. page is > 0 ? page.Value : 1,
  16. (ushort)Math.Clamp(perPage ?? 20, 1, 50)
  17. );
  18. var result = await sender.Send(query, ct);
  19. return ApiResponse.Ok(result);
  20. })
  21. .WithTags("Feed");
  22. }
  23. }