All checks were successful
CI / lint (pull_request) Successful in 1m20s
CI / build (pull_request) Successful in 1m12s
CI / unit (pull_request) Successful in 1m32s
CI / frontend (pull_request) Successful in 2m47s
CI / mutation (pull_request) Successful in 6m6s
CI / verify-stack (pull_request) Successful in 7m45s
The behandel-portal's decision reaches the domain here (via the BFF, later slices): goedkeuren/afwijzen, idempotent, superseding the temporary /approve endpoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
97 lines
4.7 KiB
C#
97 lines
4.7 KiB
C#
using Big.Application;
|
|
using Big.Domain;
|
|
using Big.Infrastructure;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Options bound from configuration (compose sets Flowable__* and Acl__* env vars).
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Flowable").Get<FlowableOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Flowable'"));
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl").Get<AclOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl'"));
|
|
|
|
// The in-memory registration store is shared between the submit endpoint and the worker (ADR-0009).
|
|
builder.Services.AddSingleton<IRegistrationStore, InMemoryRegistrationStore>();
|
|
|
|
// The Workflow Client is one type behind two ports (start side + worker side); both resolve to the
|
|
// same HttpClient-backed implementation — the only code that talks to Flowable (§8.2).
|
|
builder.Services.AddHttpClient<FlowableWorkflowClient>();
|
|
builder.Services.AddTransient<IWorkflowClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
|
builder.Services.AddTransient<IExternalWorkerClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
|
builder.Services.AddHttpClient<IAclClient, AclHttpClient>();
|
|
|
|
builder.Services.AddScoped<SubmitRegistration>();
|
|
builder.Services.AddScoped<ApproveRegistration>();
|
|
builder.Services.AddScoped<BeoordeelRegistratie>();
|
|
builder.Services.AddScoped<OpenZaakWorker>();
|
|
builder.Services.AddScoped<OpenZaakJobProcessor>();
|
|
|
|
// The hosted external-task job worker polls Flowable and drives OpenZaakAanmaken to completion.
|
|
builder.Services.AddHostedService<OpenZaakJobPump>();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapGet("/health", () => "Healthy");
|
|
|
|
// Submit a registration. The aggregate is created (INGEDIEND) and the registratie process started;
|
|
// the zaak is opened later, off the request path, by the worker — so this returns 202 Accepted with
|
|
// a location to read the registration's progress (ADR-0009, eventual consistency).
|
|
app.MapPost("/registrations", async (SubmitRegistrationRequest body, SubmitRegistration submit, CancellationToken ct) =>
|
|
{
|
|
var id = await submit.HandleAsync(new SubmitRegistrationCommand(body.Bsn), ct);
|
|
return Results.Accepted($"/registrations/{id}", new RegistrationResponse(id.ToString(), RegistrationStatus.Ingediend.ToString(), null));
|
|
});
|
|
|
|
// Temporary admin endpoint (S-09b): approve a registration — the behandelaar's decision, until the
|
|
// behandel-portal exists (S-12). The zaak's final status is set via the ACL, which flows back over
|
|
// NRC to the projection, making the entry publicly visible as INGESCHREVEN. Idempotent.
|
|
app.MapPost("/registrations/{id}/approve", async (string id, ApproveRegistration approve, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
await approve.HandleAsync(new ApproveRegistrationCommand(new RegistrationId(guid)), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// The behandelaar's beoordeling (S-12): decide a registration goedkeuren (→ INGESCHREVEN, sets the
|
|
// zaak's final status via the ACL) or afwijzen (→ AFGEWEZEN). Idempotent. This is the domain contract
|
|
// the behandel-portal's decision reaches through the BFF; it supersedes the temporary /approve above,
|
|
// which is retired once the portal lands.
|
|
app.MapPost("/registrations/{id}/decide", async (string id, DecideRequest body, BeoordeelRegistratie beoordeel, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
if (!Enum.TryParse<BeoordelingsBesluit>(body.Besluit, ignoreCase: true, out var besluit))
|
|
return Results.BadRequest(new { error = $"Unknown besluit '{body.Besluit}'. Expected 'goedkeuren' or 'afwijzen'." });
|
|
|
|
await beoordeel.HandleAsync(new BeoordeelRegistratieCommand(new RegistrationId(guid), besluit), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Read a registration. Its zaak URL appears once the worker has opened the zaak (eventually).
|
|
app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
var registration = await store.GetAsync(new RegistrationId(guid), ct);
|
|
return registration is null
|
|
? Results.NotFound()
|
|
: Results.Ok(new RegistrationResponse(
|
|
registration.Id.ToString(), registration.Status.ToString(), registration.ZaakUrl?.ToString()));
|
|
});
|
|
|
|
await app.RunAsync();
|
|
|
|
public sealed record SubmitRegistrationRequest(string Bsn);
|
|
|
|
public sealed record DecideRequest(string Besluit);
|
|
|
|
public sealed record RegistrationResponse(string RegistrationId, string Status, string? ZaakUrl);
|
|
|
|
public partial class Program;
|