candy-nest-cli
v1.0.8
Published
Scaffolding CLI for Production-grade NestJS microservices. Interactively generates scalable services with REST, GraphQL, gRPC, Kafka, RabbitMQ, BullMQ, Redis, OpenTelemetry, Prometheus, Swagger, circuit breakers, and DLQs.
Maintainers
Readme
🍬 Candy Nest CLI
Scaffold Production-Ready NestJS Microservices in Seconds.
A Simple CLI toolkit that generates secure, and fully-wired services with all the "boring" parts already done.
🚀 Advantage
Setting up a microservice usually takes hours of manual wiring. Candy Nest CLI handles the heavy lifting through code generation, giving you:
- 🛡️ Security: Global Rate Limiting, secure CORS policies, and Payload Validation (DTOs) out of the box.
- 🧪 Testing: Automated Regression E2E suite that validates your actual infrastructure (DBs, Brokers, Caching).
- 🏗️ Linking: Zero-manual-wiring for Redis, Kafka, BullMQ, and Postgres.
🛠️ Commands
1. Initialize a New Project
Interactively scaffold a complete microservice.
npx candy-nest-cli init [project-name]Features included by default:
- Infrastructure: Multi-stage
Dockerfileand optimizeddocker-compose.yml. - Observability: Prometheus metrics and root-level Health Probes.
- Security:
@nestjs/throttler(Rate Limiting) andValidationPipe(DTOs).
2. Extend an Existing Project
Add features to any standard NestJS project. The CLI detects your setup and injects the new module into AppModule automatically.
cd my-nest-app
npx candy-nest-cli add⚠️ Technical Considerations for Existing Projects
If you are adding features to a project not scaffolded with candy-nest-cli init, please note:
- Environment Setup: Our features rely on
ConfigService. You must manually copy variables from the generated.env.exampleto your.envfile. - Security Pipes: Ensure
ValidationPipeis registered inmain.tsfor our hardened DTO-based validation to take effect. - Global State: Projects initialized with this CLI have pre-configured Rate Limiting and CORS. You may need to add these manually to standard projects.
📦 Feature Matrix
| Category | Options Provided |
|---|---|
| Transport | REST (Express/Fastify), GraphQL, gRPC, WebSockets |
| Databases | PostgreSQL (TypeORM/Prisma), MySQL (TypeORM/Prisma), MongoDB (Mongoose) |
| Messaging | Kafka (Dual-listener), RabbitMQ (DLX support), BullMQ (Redis-backed) |
| Observability| Prometheus, OpenTelemetry, Jaeger Tracing, Terminus Health |
| Resiliency | Opossum Circuit Breaker, Global Rate Limiting, DLQs |
| API Docs | Swagger (@nestjs/swagger) |
🧪 Automated Regression Suite
Every project generated by Candy CLI includes a test/regression.e2e-spec.ts. Unlike standard unit tests, this suite:
- Connects to your real Docker containers.
- Performs CRUD Smoke Tests on your chosen database.
- Validates Messaging Connectivity (Kafka/RabbitMQ).
- Asserts Health Status of all infrastructure sidecars.
Run it with:
docker-compose up -d
npm run test:e2e📁 Standard Architecture
Generated projects follow a modular structure designed for scale:
src/
├── main.ts # Hardened security (CORS, Throttler, Pipes)
├── app.module.ts # Global Config (Joi validation) & Service Linking
├── database/ # Clean ORM/ODM modules
├── examples/ # Sample REST/GraphQL/gRPC logic (CRUD)
├── kafka/ # Kafka Consumers with DLQ handling
└── resiliency/ # Circuit Breaker implementations🤝 Contributing
We love PRs! If you want to add a new template (e.g., SQS support or Vitest integration), please check our CONTRIBUTING.md.
📄 License
MIT © Ashish Kushwaha
