@llodev/ts-ddd-controller
v0.1.0
Published
HTTP controllers in a TypeScript + DDD API — routes, guards, Zod validation, use-case orchestration, Result→HTTP mapping.
Maintainers
Readme
@llodev/ts-ddd-controller
HTTP controllers in a TypeScript + DDD API — routes, guards, Zod validation, use-case orchestration, and Result→HTTP mapping, with the NEVER list that keeps controllers thin.
Part of the @llodev/ts-ddd family.
What you get:
- A thin-translator contract — controllers validate at the boundary, inject use cases, and map
Result→ HTTP withmapResultToHttp; no business logic, no domain conditionals, no repository calls in a handler. - Guard placement rules — per-method
@UseGuards(ApiKeyGuard)on mutations, never at the class level, so public reads and guarded writes can coexist on the same controller. - A NestJS 11 reference layer — DI symbol tokens,
@Inject(SYMBOL),@Global()modules, Zod-validatedConfigModule.forRoot, and the@nestjs/testing+supertesttest bed actually used in production code. - Response-mapper discipline — signed-URL enrichment, date serialization, and tagged-union variants funnel through a dedicated mapper instead of leaking entity internals.
- A
NEVERlist grounded in real failure modes: class-level guards that 401 public reads, inlineHttpExceptionthrows that fork the error-code catalog,new UseCase(...)that breaks DI and tests.
Install
# npm (with skillpm or Claude Code marketplace)
npm i @llodev/ts-ddd-controller
# Vercel CLI
npx skills add llodev/skills/skills/ts-ddd-controllerNo MCP, no config, no init — it's a pure knowledge skill. Once installed it activates on prompts like the ones below.
Use
| Prompt example | What the agent does |
| --------------------------------------------------- | ------------------------------------------------------------------------------------ |
| "add a POST /celebrations/:slug/publish endpoint" | Emits a controller method with ApiKeyGuard, ZodValidationPipe, mapResultToHttp |
| "why is this write endpoint returning 401?" | Checks guard placement (class-level vs per-method) against the NEVER list |
| "review this controller" | Checks for business logic leakage, new UseCase(), raw HttpException throws |
| "wire this controller's response for signed URLs" | Routes entity → response through a dedicated response mapper |
Contents
| File | Content |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| SKILL.md | Trigger conditions, folder layout, before-you-start checklist, core rules, and NEVER list for controllers. |
| references/controller-pattern.md | Repo-grounded: folder layout, ZodValidationPipe, ApiKeyGuard semantics, mapResultToHttp, response mapper, test strategy. |
| references/nestjs.md | NestJS 11 patterns: DI symbol tokens, @Inject(SYMBOL), @Global() modules, Zod-validated ConfigModule.forRoot, test bed. |
| examples/product.controller.nestjs.ts | Runnable-style mirror of a production controller, showing guard placement and Result → HTTP mapping. |
License
MIT — see LICENSE.
