Prompt file imported from oleksa-karpenko/LLeague (
.github/prompts/add-endpoint.prompt.md). Copyright stays with the author.
Add a new API endpoint to the backend, respecting the Clean Architecture layering.
Ask me for (or infer from context): the route, HTTP verb, request/response shape, and auth requirement.
Then implement, in this order:
- DTOs — add request/response
records to the appropriateApplication/*Dtos.cs. - Application service — add the use-case method to the relevant
Application/Services/*Service.cs(or create a new service + register it inApplication/DependencyInjection.cs). InjectIAppDbContext. Throw domain exceptions (ValidationException,NotFoundException,UnauthorizedException,ConflictException) for error cases — never return status codes from the service. - Controller action — add a thin action to the matching
Controllers/*Controller.cs: correct verb/route attribute,[Authorize]/[AllowAnonymous], and a one-line delegation to the service. No business logic, no try/catch (the middleware handles exceptions). - Tests — add xUnit integration tests (
[Collection(ApiCollection.Name)],PostgresFixture) covering the happy path and the domain-exception paths. See.github/instructions/backend-tests.instructions.md.
Finally run cd backend && dotnet format LLeague.slnx && ./coverage.sh and confirm it's green.