Refactor runtime bootstrap and ship control flows
This commit is contained in:
25
apps/backend/Universe/Api/CreateFactionHandler.cs
Normal file
25
apps/backend/Universe/Api/CreateFactionHandler.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using FastEndpoints;
|
||||
|
||||
namespace SpaceGame.Api.Universe.Api;
|
||||
|
||||
public sealed class CreateFactionHandler(WorldService worldService) : Endpoint<CreateFactionCommandRequest, FactionSnapshot>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/gm/factions");
|
||||
Policies(AuthPolicyNames.GmAccess);
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateFactionCommandRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await SendOkAsync(worldService.CreateFaction(request.FactionId), cancellationToken);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
AddError(ex.Message);
|
||||
await SendErrorsAsync(cancellation: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user