21 lines
673 B
C#
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);
|
|
}
|
|
} |