This commit is contained in:
john 2025-05-03 15:38:57 +02:00
commit ab2e20f7e1
72 changed files with 2000 additions and 0 deletions

View file

@ -0,0 +1,3 @@
namespace Femto.Api.Controllers.Posts.Dto;
public record CreatePostRequest(Guid AuthorId, string Content, IEnumerable<Uri> Media);

View file

@ -0,0 +1,3 @@
namespace Femto.Api.Controllers.Posts.Dto;
public record CreatePostResponse(Guid PostId);

View file

@ -0,0 +1,6 @@
namespace Femto.Api.Controllers.Posts.Dto;
public record GetPostResponse
{
}

View file

@ -0,0 +1,25 @@
using Femto.Api.Controllers.Posts.Dto;
using Femto.Modules.Blog.Domain.Posts.Commands.CreatePost;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace Femto.Api.Controllers.Posts;
[ApiController]
[Route("posts")]
public class PostsController(IMediator mediator) : ControllerBase
{
[HttpPost]
public async Task<ActionResult<CreatePostResponse>> Post(
[FromBody] CreatePostRequest req,
CancellationToken cancellationToken
)
{
var guid = await mediator.Send(
new CreatePostCommand(req.AuthorId, req.Content, req.Media),
cancellationToken
);
return new CreatePostResponse(guid);
}
}