Scaffold a New NestJS Module
Create a full feature module with CRUD operations following this project's conventions.
Steps
- •Create the entity in
src/entities/{name}.entity.tsusing the entity template - •Create the model file in
src/modules/{name}/{name}.model.tsusing the model template - •Create the service in
src/modules/{name}/{name}.service.tsusing the service template - •Create the controller in
src/modules/{name}/{name}.controller.tsusing the controller template - •Create the module in
src/modules/{name}/{name}.module.tsusing the module template - •Register the module by adding it to the
src/modules/index.tsexports array
Critical Conventions
- •All class properties, columns, route paths, and method names use PascalCase
- •Use path aliases:
@entities/*,@common/*,@modules/*,@decorators/* - •Response models must have
@Expose()on every property (ClassSerializerInterceptor usesexcludeExtraneousValues: true) - •Use
@ApiSuccessResponse(Type)for single-object endpoints,@ApiSuccessArrayResponse(Type)for lists - •Use
@ApiSuccessResponse('boolean')for Create/Edit/Delete that returnboolean - •For paginated lists, set
request.TotalRowCountviaasyncLocalStoragein the service - •Use
plainToInstance()to convert entities to response models - •Entity constructors:
constructor(partial: Partial<T>) { Object.assign(this, partial); } - •Soft delete via
@DeleteDateColumn()andrepository.softDelete()