1.0.5 ⢠Published 6 months ago
nest-generator-cli v1.0.5
Nest Generator CLI
A powerful CLI tool for generating NestJS modules with Prisma integration. Quickly scaffold CRUD modules with proper TypeScript types, Swagger documentation, and Prisma schema integration.
Features
- š Generate complete NestJS CRUD modules
- š Auto-generate Prisma schema models
- š Create DTOs with validation
- š Swagger/OpenAPI documentation
- šÆ TypeScript support
- ā” Proper naming conventions
- š Interactive CLI interface
Installation
npm install -g nest-generator-cli
Usage
Run the generator:
nest-gen
Or using npx:
npx nest-generator-cli
The CLI will guide you through: 1. Entering the model name 2. Defining fields and their types 3. Setting up relationships 4. Generating all necessary files
Generated Files Structure
For each model, the following files are generated:
src/
āāā your-model/
āāā dto/
ā āāā create-your-model.dto.ts
ā āāā update-your-model.dto.ts
āāā your-model.controller.ts
āāā your-model.service.ts
āāā your-model.module.ts
And in your Prisma schema:
prisma/
āāā models/
āāā your-model.prisma
Features in Detail
1. Model Generation
- Automatic Prisma schema generation
- Support for all common data types
- Relationship handling (One-to-One, One-to-Many, Many-to-Many)
- Proper timestamps and ID fields
2. API Generation
- Complete CRUD operations
- Request validation
- Swagger documentation
- Proper error handling
3. Type Safety
- TypeScript interfaces
- DTO validation
- Prisma client type generation
4. Best Practices
- Follows NestJS conventions
- Proper file organization
- Clean code structure
- Consistent naming
Configuration
The generator uses your project's existing Prisma configuration. Make sure you have a valid DATABASE_URL
in your .env
file:
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
Requirements
- Node.js >= 14
- NestJS project
- Prisma setup in your project
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
MIT License - see the LICENSE file for details# nest-generator-cli