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