A CLI tool for generating NestJS modules, controllers, services, and entities with interactive prompts
npm install gmt-lazynest

A powerful CLI tool for generating NestJS modules, controllers, services, and entities with interactive prompts. LazyNest helps you scaffold NestJS applications quickly and efficiently.
- š Interactive CLI: User-friendly prompts for generating modules
- š Module Generator: Complete module structure with controller, service, repository, DTOs, and entities
- šļø Project Initialization: Set up common NestJS project structure
- šÆ TypeORM Integration: Built-in support for TypeORM entities and repositories
- ļæ½ Git Hooks: Pre-configured Husky hooks for code quality (lint, format, commit validation)
- š Template-based: Consistent code generation using predefined templates
- šØ Conventional Commits: Enforce commit message standards with commitlint
- š§ Customizable: Flexible attribute types and configurations
- š¦ Node Version Management: Automatic .nvmrc generation for consistent Node versions
Install globally using npm:
``bash`
npm install -g gmt-lazynest
Or using pnpm:
`bash`
pnpm add -g gmt-lazynest
`bash`
lzn init
This command will:
- Set up common NestJS project structure (common, config, database folders)
- Configure TypeORM integration
- Generate base classes and utilities
- Create Husky git hooks for code quality:
- Pre-commit hook (lint & format)
- Commit-msg hook (conventional commits validation)
- Pre-push hook (run tests)
- Add .nvmrc file for Node version managementcommitlint.config.js
- Add for commit message linting.lintstagedrc.js
- Add for staged files lintingpackage.json
- Update with TypeORM migration scripts
- Automatically clean and reinstall dependencies using pnpm
The init command will automatically run rm -rf node_modules pnpm-lock.yaml && pnpm install at the end to ensure all dependencies are properly installed.
> Note: Make sure you have pnpm installed globally. If not, install it first: npm install -g pnpm
`bash`
lzn module
This command will generate:
- Module file
- Controller with CRUD endpoints
- Service with business logic
- Repository for database operations
- DTOs for request/response
- Entity with TypeORM decorators
When you generate a module, LazyNest creates a complete structure:
``
src/
modules/
your-module/
āāā your-module.module.ts
āāā your-module.controller.ts
āāā your-module.service.ts
āāā your-module.repository.ts
āāā dto/
ā āāā create-your-module.dto.ts
ā āāā update-your-module.dto.ts
ā āāā filtering-your-module.dto.ts
ā āāā response-your-module.dto.ts
āāā entities/
ā āāā your-module.entity.ts
āāā interfaces/
āāā your-module.interface.ts
`bash`
$ lzn module
? Enter your module name: User
? Enter your attribute name (user): name
? Select attribute type (user - name): String
? Enter your attribute name (user): email
? Select attribute type (user - email): String
? Enter your attribute name (user): age
? Select attribute type (user - age): Number
? Do you want to add another attribute? No
This generates a complete user module with name, email, and age attributes.
`bash`
lzn version
Displays the current LazyNest version.
After running lzn init, your project will have:
``
.
āāā .husky/
ā āāā pre-commit # Runs lint & format before commit
ā āāā commit-msg # Validates commit messages
ā āāā pre-push # Runs tests before push
āāā .nvmrc # Node version specification
āāā commitlint.config.js # Commit message linting rules
āāā .lintstagedrc.js # Lint-staged configuration
āāā src/
āāā common/ # Common utilities and base classes
ā āāā bases/ # Base entity, repository, service classes
ā āāā decorators/ # Custom decorators
ā āāā dto/ # Common DTOs (pagination, query params)
ā āāā interfaces/ # Shared interfaces
ā āāā swagger/ # Swagger documentation helpers
āāā config/ # Configuration module
āāā database/ # Database configuration and migrations
āāā app.module.ts # Root application module
āāā main.ts # Application entry point
- Node.js >= 16
- NestJS project
- TypeORM (for database integration)
To test LazyNest locally without publishing to npm:
1. Build the project:
- pnpm (for dependency management) - Install with: npm install -g pnpm
`bash`
cd /path/to/lazynest
npm run build
2. Run directly:
`bash`
node dist/src/main.js init
# or
node dist/src/main.js module
3. Using npm link (optional):
`bash`
npm link
# Then in another project:
lzn init
4. Using npm pack:
`bash`
npm pack
# Install in test project:
npm install /path/to/gmt-lazynest-1.x.x.tgz
1. Commit your changes:
`bash`
git add .
git commit -m "feat: your feature description"
2. Update version (choose one):
`bash`
npm run release:patch # Bug fixes (1.1.3 -> 1.1.4)
npm run release:minor # New features (1.1.3 -> 1.2.0)
npm run release:major # Breaking changes (1.1.3 -> 2.0.0)
3. Publish to npm:
`bash`
npm run publish:npm
4. Push to GitHub:
`bash``
git push --follow-tags origin master
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this tool helpful, please consider giving it a ā on GitHub!
Created by Developer Gamatecha
- Author - Developer Gamatecha
- Website - https://gamatecha.com/
Nest is MIT licensed.
[Backend]