DTO Generator
This skill automates the creation of Data Transfer Objects (DTOs) following the project's standards for validation and documentation.
Workflow
- •Identify the DTO name: Use PascalCase (e.g.,
CreateUserDto,UpdateProfileRequest). - •Identify the module and type: Requests go to
dto/requests, Responses todto/responses. - •Execute the generator script: Provide the name and module.
- •Define properties: The script will prompt or you can edit the file to add specific fields.
Usage
Run the following command from the project root:
bash
node .gemini/skills/dto-generator/scripts/generate_dto.cjs <module-name> <dto-name> <type: request|response>
Example
To create a UpdatePasswordRequest in the auth module:
bash
node .gemini/skills/dto-generator/scripts/generate_dto.cjs auth UpdatePasswordRequest request
This will:
- •Create
src/modules/auth/dto/requests/update-password-request.dto.ts. - •Scaffold the class with
@ApiPropertyand basicclass-validatorplaceholders.
Standards Applied
- •File Naming: kebab-case (e.g.,
update-password-request.dto.ts). - •Validation:
class-validatordecorators. - •Documentation:
@nestjs/swaggerdecorators.