| 123456789101112131415161718192021222324252627282930313233343536 |
- using MediatR;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Developers.Apps;
- internal sealed class Create : IEndpoint
- {
- public sealed record Request(string Name, string? Description, string? HomepageUrl, List<string>? Scopes);
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/developers/apps", async (
- Request body,
- HttpContext httpContext,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = httpContext.User.GetRequiredMemberID();
- var command = new Application.Features.Api.Developers.Apps.CreateApp.Command(
- memberID,
- body.Name,
- body.Description,
- body.HomepageUrl,
- body.Scopes ?? []
- );
- var result = await sender.Send(command, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("Developers")
- .RequireAuthorization();
- }
- }
|