Careeroza
Generate a Resource
A Complete CRUD Skeleton in One Command
Example
nest g resource categoriesExample 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
- Add fields and class-validator rules to the DTOs.
- Define the entity (TypeORM) or model (Prisma).
- Replace the placeholder strings in the service (
return 'This action adds a new category') with real logic. - Add
ParseIntPipeto:idparams (the generated code uses+id).
Tip: Other transport choices: GraphQL (code first / schema first), Microservice, WebSockets. The CLI generates the right resolver or gateway.