A powerful CLI tool to scaffold production-ready Express.js applications with a clean Repository Pattern architecture.
npm install khushikumarigupta14-express-generator-clinpx:
bash
Initialize a new project
npx khushikumarigupta14-express-generator-cli init my-app
`
Or install it globally:
`bash
npm install -g khushikumarigupta14-express-generator-cli
Then use the shorter command
my-express-gen init my-app
`
⨠Features
- Repository Pattern: Clean separation of concerns (Controller ā Service ā Repository ā Model).
- TypeScript: Fully typed codebase.
- Swagger Docs: Auto-generated API documentation.
- Zod Validation: Runtime request validation.
- Module Generator: Quickly scaffold new feature modules.
š Commands
$3
Scaffolds a fresh project by cloning the boilerplate and setting up a clean Git environment.
`bash
npx khushikumarigupta14-express-generator-cli init
`
Example:
`bash
npx khushikumarigupta14-express-generator-cli init ecommerce-api
cd ecommerce-api
npm install
npm run dev
`
$3
Generates a complete module structure in src/modules/ including:
- Controller
- Service
- Repository
- Model (Mongoose)
- Routes
- Interfaces
- Validation (Zod)
- Swagger Documentation
Usage:
Navigate to your project root and run:
`bash
npx khushikumarigupta14-express-generator-cli generate module
OR alias
npx khushikumarigupta14-express-generator-cli g module
`
Example:
`bash
npx khushikumarigupta14-express-generator-cli g module products
`
This will create a products module and output instructions on how to register the route in app.ts.
š¦ Project Structure Scaffolding
When you generate a module (e.g., orders), it creates:
`
src/modules/orders/
āāā orders.controller.ts # Handles HTTP requests
āāā orders.service.ts # Business logic
āāā orders.repository.ts # Database access
āāā orders.model.ts # Mongoose Schema
āāā orders.interface.ts # TypeScript Interfaces
āāā orders.validation.ts # Zod Schemas
āāā orders.routes.ts # Express Router
āāā orders.docs.ts # Swagger/OpenAPI Defs
āāā index.ts # Module exports
``