Generate a Resource

A Complete CRUD Skeleton in One Command

Example

nest g resource categories

Example output

? What transport layer do you use? REST API
? Would you like to generate CRUD entry points? Yes
CREATE src/categories/categories.controller.spec.ts (606 bytes)
CREATE src/categories/categories.controller.ts (979 bytes)
CREATE src/categories/categories.module.ts (276 bytes)
CREATE src/categories/categories.service.spec.ts (481 bytes)
CREATE src/categories/categories.service.ts (673 bytes)
CREATE src/categories/dto/create-category.dto.ts (34 bytes)
CREATE src/categories/dto/update-category.dto.ts (185 bytes)
CREATE src/categories/entities/category.entity.ts (25 bytes)
UPDATE src/app.module.ts (412 bytes)

What You Still Have to Do

  1. Add fields and class-validator rules to the DTOs.
  2. Define the entity (TypeORM) or model (Prisma).
  3. Replace the placeholder strings in the service (return 'This action adds a new category') with real logic.
  4. Add ParseIntPipe to :id params (the generated code uses +id).

Tip: Other transport choices: GraphQL (code first / schema first), Microservice, WebSockets. The CLI generates the right resolver or gateway.