Files
BeReadyBackend/BeReadyBackend/Endpoints/Posts/GetAllPostsEndpoint.cs
T
2026-04-21 11:04:25 +02:00

21 lines
673 B
C#

using BeReadyBackend.DTO.Posts;
using BeReadyBackend.Repositories;
using BeReadyBackend.Services;
using BeReadyBackend.Specifications.Posts;
using FastEndpoints;
namespace BeReadyBackend.Endpoints.Posts;
public class GetAllPostsEndpoint(PostsRepository postsRepository, UserService userService) : EndpointWithoutRequest<List<GetPostDto>>
{
public override void Configure()
{
Get("/Posts/");
}
public override async Task HandleAsync(CancellationToken ct)
{
int userId = userService.GetUserIdFromToken();
await Send.OkAsync(await postsRepository.ProjectToListAsync<GetPostDto>(new GetPostNotMeSpec(userId), ct), ct);
}
}