cube-ms
Version:
Production-ready microservice framework with health monitoring, validation, error handling, and Docker Swarm support
338 lines (262 loc) โข 11.9 kB
Markdown
# ๐ Cube Microservice v2.0.0-beta.5 - Refined CLI & Template System
**Bug Fix Release** - Enhanced CLI experience, robust template system, and improved error handling
## ๐ง **What's Fixed in v2.0.0-beta.5**
### ๐ฏ **CLI Improvements**
- **โ
FIXED**: Step counter now shows correct 3/4, 4/4 instead of confusing 3/5, 4/5
- **โ
IMPROVED**: CCN registry setup now creates .npmrc.template automatically when missing
- **โ
ENHANCED**: Better error messages and graceful handling of missing files
- **โ
ADDED**: Comprehensive automated tests covering all CLI generation scenarios
### ๐ ๏ธ **Template System Overhaul**
- **โ
FIXED**: API template now includes all required scripts (setup-git-hooks.js, validate-env.js)
- **โ
ADDED**: Flexible postinstall-helper.js for graceful script execution
- **โ
IMPROVED**: Templates now handle missing dependencies without breaking installation
- **โ
ENHANCED**: Complete .env.example files for all templates
### ๐ **Error Handling & Resilience**
- **โ
ROBUST**: Postinstall scripts now continue on errors instead of failing installation
- **โ
SMART**: Missing script detection with helpful fallback messages
- **โ
VALIDATED**: All templates tested for required files and script consistency
- **โ
SECURE**: Better handling of sensitive configuration files
## ๐งช **Testing Improvements**
- **NEW**: Comprehensive CLI generation test suite
- **COVERAGE**: All templates (basic, api) tested for consistency
- **VALIDATION**: Project name validation, error handling, and edge cases
- **RELIABILITY**: Automated tests prevent future template breakage
## ๐ฆ **Updated Files**
- `bin/cube-ms.js` - Fixed step counter, improved .npmrc template creation
- `templates/api/scripts/setup-git-hooks.js` - Added missing Git hooks setup
- `templates/api/scripts/postinstall-helper.js` - New flexible postinstall system
- `templates/api/scripts/validate-env.js` - Added environment validation
- `templates/api/.env.example` - Complete environment configuration
- `templates/api/package.json` - Updated to use flexible postinstall
- `test/cli-generation.test.js` - New comprehensive CLI test suite
## ๐ฏ **Migration from v2.0.0-beta.4**
**โ
Zero Breaking Changes** - This is purely a bug fix release
**Improved User Experience:**
- CLI now shows correct step numbers
- Missing files no longer cause installation failures
- Better error messages guide users through setup
- CCN registry setup is more robust
# ๐ Cube Microservice v2.0.0-beta.4 - Complete Multi-Database & Enterprise CLI
**Major Feature Release** - Full multi-database implementation, interactive CLI with TypeScript support, and comprehensive enterprise features
## ๐ฏ **What's New in v2.0.0-beta.4**
### ๐๏ธ **Multi-Database Architecture** (COMPLETE)
- **โจ NEW**: Complete multi-database manager with transaction support
- **๐ Named Connections**: Access databases by logical names (primary, analytics, logs, etc.)
- **๐ Cross-Database Transactions**: Multi-database transactions with automatic rollback
- **๐ Health Monitoring**: Individual database health checks and status aggregation
- **๐ Security**: URL masking for sensitive connection strings
- **โก Performance**: Connection pooling and efficient resource management
```javascript
const service = CreateService({
port: 3000,
databases: {
primary: {
url: 'mongodb://localhost:27017/my_app',
config: { description: 'Main application database' }
},
analytics: {
url: 'mongodb://localhost:27017/analytics',
config: { description: 'Analytics and reporting' }
}
}
});
// Cross-database transactions
await service.withDatabaseTransaction(['primary', 'analytics'], async (dbs, sessions) => {
await dbs.primary.db.collection('orders').insertOne(order, { session: sessions.primary });
await dbs.analytics.db.collection('metrics').insertOne(metrics, { session: sessions.analytics });
});
```
### ๐ **Interactive CLI 2.0** (MAJOR UPGRADE)
- **๐ฏ 4-Step Project Wizard**: Language โ Port โ Database โ Template
- **๐ต๐ก Language Support**: Full JavaScript/TypeScript support with auto-configuration
- **๐๏ธ Multi-Database Setup**: Interactive multi-database configuration wizard
- **๐ Project Validation**: Smart project name validation and conflict detection
- **โก Non-Interactive Mode**: Full command-line options for CI/CD
**Interactive Experience:**
```bash
๐ฏ Setting up your cube-ms project: my-app
1/4 Choose your programming language:
โฏ ๐ก JavaScript ๐ต TypeScript
3/4 Configure database connection:
โฏ ๐ฆ Single Database
๐๏ธ Multiple Databases - Connect to multiple MongoDB instances
```
### ๐ต **TypeScript First-Class Support** (NEW)
- **๐ Complete Project Generation**: Full TypeScript project scaffolding
- **โ๏ธ Auto-Configuration**: `tsconfig.json`, dependencies, build scripts
- **๐ฅ Hot Reload**: Development server with ts-node integration
- **๐ ๏ธ Build Tools**: Separate build, type-check, and development commands
- **๐ฏ Type Safety**: Generated code with proper type annotations
```bash
# Full TypeScript project creation
cube-ms create my-ts-app --language typescript
# TypeScript development workflow
npm run dev # Hot reload with ts-node
npm run build # Compile to JavaScript
npm run type-check # Type checking without compilation
```
### ๐ ๏ธ **Enhanced Development Experience**
- **๐ง Advanced Code Generation**: CRUD operations, API documentation generation
- **๐ณ Environment Validation**: Docker Compose consistency checking
- **๐ Pre-Deployment Validation**: Automated environment verification
- **๐ Git Hooks Integration**: Quality enforcement with setup automation
- **๐ Enhanced Monitoring**: Performance tracking and health checks
### ๐งช **Comprehensive Testing Suite** (NEW)
- **8 New Test Files**: Complete test coverage for new components
- **๐ Multi-Database Testing**: Transaction and health monitoring tests
- **๐ก๏ธ Security Testing**: Rate limiting and validation tests
- **โก Performance Testing**: Monitoring and optimization tests
- **๐ฏ Integration Testing**: End-to-end workflow validation
## ๐ **New CLI Commands**
### **Environment & Validation**
```bash
cube-ms validate-docker # Validate Docker Compose environments
cube-ms fix-env --docker-compose # Auto-fix environment issues
cube-ms pre-deploy <environment> # Pre-deployment validation
cube-ms setup-hooks # Setup Git hooks for quality enforcement
```
### **Enhanced Development**
```bash
cube-ms dev --minimal # Minimal mode (faster startup)
cube-ms dev --no-dashboard # Disable development dashboard
cube-ms dev --no-security # Disable security in development
cube-ms start --cluster # Start with cluster mode
```
### **Code Generation**
```bash
cube-ms generate docs # Generate API documentation
cube-ms generate route user --crud # Full CRUD API generation
```
## ๐ง **API Enhancements**
### **New Multi-Database Methods**
```javascript
// Get specific database
const primaryDb = await service.getDatabase('primary');
// Get multiple databases
const { primary, analytics } = await service.getDatabases(['primary', 'analytics']);
// Health monitoring
const health = await service.checkDatabaseHealth();
const stats = service.getDatabaseStats();
// Cross-database transactions
await service.withDatabaseTransaction(databaseNames, callback);
```
### **Enhanced Service Configuration**
```javascript
const service = CreateService({
port: 3000,
// NEW: Multi-database support
databases: {
primary: 'mongodb://localhost:27017/app',
analytics: {
url: 'mongodb://localhost:27017/analytics',
config: { description: 'Analytics database' }
}
},
// Enhanced existing features
enableSecurity: true,
enableRateLimit: true,
enablePerformanceMonitoring: true
});
```
## ๐ฆ **Dependencies & Infrastructure**
### **Updated Dependencies**
- **inquirer**: `^9.3.7` - Enhanced interactive CLI experience
- **axios**: `^1.7.9` - Reliable HTTP client (replaced deprecated got)
- **commander**: `^9.5.0` - Advanced CLI argument parsing
- **chokidar**: `^3.5.0` - File watching for development server
### **New Components**
- `src/multi_database_manager.js` - Complete multi-database management
- `test/multi-database-manager.test.js` - Comprehensive database tests
- `test/rate-limiter.test.js` - Rate limiting functionality tests
- `test/security-validator.test.js` - Security validation tests
- `test/performance-monitor.test.js` - Performance monitoring tests
- Enhanced CLI with 1000+ lines of new functionality
## ๐ **Migration Guide**
### **From v2.0.0-beta.3 to v2.0.0-beta.4**
**โ
Zero Breaking Changes** - All existing code continues to work
**๐ง To Use Multi-Database Features:**
```javascript
// Before (still works)
const service = CreateService({ port: 3000 });
// After (new capability)
const service = CreateService({
port: 3000,
databases: {
primary: 'mongodb://localhost:27017/app',
analytics: 'mongodb://localhost:27017/analytics'
}
});
```
**๐ Enhanced CLI Usage:**
```bash
# Interactive project creation (new default)
cube-ms create my-app
# Non-interactive with all options
cube-ms create my-app --language typescript --template api --port 8080 --no-interactive
```
## ๐ **Performance & Quality**
### **Test Coverage**
- **14 Test Files**: Comprehensive coverage of all components
- **Multi-Database**: Transaction safety and health monitoring
- **Security**: XSS, SQL injection, rate limiting protection
- **Performance**: Memory, CPU, and response time monitoring
- **Integration**: End-to-end workflow validation
### **Quality Assurance**
- **Zero Breaking Changes**: Full backward compatibility maintained
- **Professional Code Quality**: Proper error handling, logging, cleanup
- **Security Focus**: Input validation, credential masking, secure defaults
- **Production Ready**: Comprehensive monitoring and health checks
## ๐ณ **Docker & Production**
### **Environment Validation**
```bash
# Validate Docker Compose consistency
npm run validate-docker-env
# Auto-fix environment issues
npm run fix:docker-env
# Pre-deployment checks
npm run pre-deploy:prod
```
### **Enhanced Health Checks**
- Individual database health monitoring
- Cross-database transaction health
- Performance metrics aggregation
- Comprehensive service status reporting
## ๐ **Compatibility**
- **โ
Node.js**: >=16.14.0
- **โ
MongoDB**: ^6.10.0
- **โ
TypeScript**: ^5.3.3 (optional)
- **โ
Docker**: Full container support
- **โ
Kubernetes**: Health check endpoints
## ๐ค **Contributing & Feedback**
This is a **beta release** with active development. Please report any issues or feedback to help us improve the framework before the stable v2.0.0 release.
### **What's Next**
- **v2.0.0-stable**: Final release with performance optimizations
- **GraphQL Integration**: Enhanced GraphQL server implementation
- **Advanced Caching**: Redis integration and multi-tier caching
- **Deployment Automation**: Enhanced Docker and Kubernetes support
## ๐ **Documentation Updates**
- **[README.md](./README.md)**: Complete feature documentation
- **[CLI.md](./CLI.md)**: Interactive CLI guide
- **[Multi-Database Guide](./README.md#multi-database-support)**: Database management
- **[TypeScript Guide](./README.md#typescript-support)**: TypeScript integration
**Version**: 2.0.0-beta.4
**Release Date**: 2025-01-19
**Node.js**: >=16.14.0
**License**: MIT
**๐ This release represents a major milestone in the Cube Microservice framework evolution, providing enterprise-grade multi-database capabilities with an exceptional developer experience.**