nest-generator-cli
v1.0.5
Published
A CLI tool for generating NestJS modules with Prisma integration
Maintainers
Readme
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-cliUsage
Run the generator:
nest-genOr using npx:
npx nest-generator-cliThe CLI will guide you through:
- Entering the model name
- Defining fields and their types
- Setting up relationships
- 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.tsAnd in your Prisma schema:
prisma/
└── models/
└── your-model.prismaFeatures 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
