Move the authoritative business rules off the frontend into a real backend,
realising the BFF-lite + decision-DTO design (ADR-0001) that until now lived
only in static mock JSON.
Backend (backend/):
- ASP.NET Core (.NET 10) minimal API, contract-first, Swagger UI at /swagger.
- DDD Domain/ rules layer: profession derivation + applicable policy questions
(DiplomaRules), herregistratie eligibility + reason (HerregistratieRule),
scholing threshold (IntakePolicy), submit rejections + reference generation
(SubmissionRules). In-memory seeded data, ProblemDetails (RFC 7807) errors.
- 27 xUnit tests: rule units + endpoint integration incl. BRP no-address and
DUO not-found fallbacks and 422 submit paths.
Frontend (only infrastructure/ + contracts/ change, as the architecture promised):
- NSwag-generated typed client (api-client.ts), routed through Angular HttpClient
via a small fetch adapter so the ?scenario= interceptor still applies.
- GET adapters use resource({ loader: client.x }); submit commands call the client
and map ProblemDetails -> err. The hardcoded uren==0 / manual-diploma rules are
deleted (now server-side). Domain, stores, UI and format validators unchanged.
- Deleted the now-dead public/mock/*.json.
Tooling/docs:
- npm start proxies /api -> backend; npm run gen:api regenerates the client;
docker compose up runs both (bind mounts use :z for SELinux/Fedora).
- backend/README.md walkthrough: adding a policy question is a one-file backend
change, no FE change, no client regen. Updated CLAUDE.md + ARCHITECTURE.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
767 B
TypeScript
19 lines
767 B
TypeScript
import { Result, ok, err } from '@shared/kernel/fp';
|
|
import { ValidIntake } from '../domain/intake.machine';
|
|
import { ApiClient } from '@shared/infrastructure/api-client';
|
|
import { problemDetail } from '@shared/infrastructure/api-error';
|
|
|
|
/**
|
|
* Command: POST the intake questionnaire to the backend (`/api/intakes`). The
|
|
* "uren must be > 0" rule now lives server-side; the backend returns a 422
|
|
* ProblemDetails on rejection, which we surface as the error.
|
|
*/
|
|
export async function submitIntake(client: ApiClient, data: ValidIntake): Promise<Result<string, void>> {
|
|
try {
|
|
await client.intakes({ uren: data.uren });
|
|
return ok(undefined);
|
|
} catch (e) {
|
|
return err(problemDetail(e, 'Het indienen is niet gelukt. Probeer het later opnieuw.'));
|
|
}
|
|
}
|