/nest-vertical-slice — add a NestJS feature the way this repo already does it
Builds a new feature end-to-end matching the patterns already in the repo's src/ — pick the closest existing module as your reference (controller + service + dto/).
Input
Feature name + what it does. Optionally: fields/model, auth requirement, whether it needs a Prisma table.
Discover conventions BEFORE writing
- Open an existing slice (e.g.
src/<some-feature>/+ itsdto/) and copy its shape: decorators, validation style (class-validator), service injection, error handling, response shape. - Check how modules register (
app.module.tsimports) and how auth guards / RBAC are applied — match whatever the repo already does. - Check any shared package for types/enums to reuse instead of redefining.
Procedure
- Create
src/<feature>/:<feature>.module.ts,<feature>.controller.ts,<feature>.service.tsdto/create-<feature>.dto.ts,dto/update-<feature>.dto.tswithclass-validatordecorators
- If a DB table is needed → hand off the schema change to
/prisma-migrate-safe(do not hand-edit migrations here). - Register the module in
app.module.ts. Apply the same guards/decorators as sibling modules. - Use Prisma service the same way existing services do (constructor injection).
- Add i18n keys for any user-facing strings via /i18n-sync.
npx tsc --noEmit(or the repo's typecheck script) to prove it compiles.
Conventions to honour
- Comments: match the surrounding file's language convention (this author uses Thai for business logic, English for technical).
- Match the surrounding code's naming/idiom; don't introduce a new style.
- Don't add libraries the repo doesn't already use.