UNPKG

cube-ms

Version:

Production-ready microservice framework with health monitoring, validation, error handling, and Docker Swarm support

338 lines (262 loc) โ€ข 11.9 kB
# ๐Ÿš€ 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.**