using MediatR; using Web.Api.Extensions; using Web.Api.Common; namespace Web.Api.Endpoints.Auth; internal sealed class Register : IEndpoint { public sealed record Request( string Email, string Password, string? Name ); public void MapEndpoint(IEndpointRouteBuilder app) { app.MapPost("api/auth/register", async ( Request request, ISender sender, CancellationToken ct ) => { var command = new Application.Features.Auth.Register.Command( request.Email, request.Password, request.Name ); var result = await sender.Send(command, ct); return result.Match( id => Results.Created($"/api/auth/profile", new { id }), CustomResults.Problem ); }) .WithTags("Auth") .AllowAnonymous(); } }