Reusable framework for Lego-style software architecture on Cloudflare Workers + D1
npm install @tamyla/lego-frameworkjavascript
// Security validation runs automatically on every deployment
hooks: {
'pre-deployment': async (context) => {
const issues = ConfigurationValidator.validate(config, environment);
if (criticalIssues.length > 0) {
throw new Error('š« Deployment blocked due to critical security issues');
}
}
}
`
$3
`bash
Generate secure keys
npx lego-security generate-key jwt
npx lego-security generate-key api content-skimmer
Validate configuration security
npx lego-security validate customer production
Deploy with automatic security validation
npx lego-security deploy customer production
`
Current Status ā
$3
- ā
Interactive Domain Selection: Choose domains from discovered services
- ā
Real Cloudflare Worker Deployment: Actual wrangler-based deployment
- ā
Domain Discovery & Validation: Comprehensive Cloudflare integration
- ā
API Token Management: Secure encrypted storage and validation
- ā
Service Directory Intelligence: Smart service discovery by domain configuration
- ā
Production Testing Suite: Comprehensive post-deployment validation
- ā
Deployment Auditing: Complete audit trails and logging
- ā
Graceful Error Handling: D1 permission graceful degradation
- ā
Cross-Platform Support: Windows PowerShell and Linux compatibility
- ā
š Security Validation Framework: Automated security validation and deployment blocking
- ā
š”ļø Cryptographic Key Generation: Secure API key and JWT secret generation
- ā
š« Deployment Security: Pre-deployment validation that blocks insecure configurations
- ā
š„ Customer Configuration Management: Multi-environment, multi-customer configuration system
- ā
šļø Template-Based Customer Onboarding: Automated customer setup from reusable templates
- ā
š Framework Integration: Customer configs integrate with domain and feature flag systems
- ā
š TypeScript Support: Comprehensive type definitions with 500+ lines of TypeScript interfaces
- ā
ā” Performance Caching: Schema caching, SQL query caching, and validation result caching
- ā
š Enhanced Data Services: Advanced pagination, relationship loading, and query optimization
$3
- Enterprise Deployment System: Multi-domain deployment orchestration with validation
- Domain Configuration Management: Centralized configuration with runtime discovery
- API Token Security: AES-256-CBC encrypted storage with automatic prompting
- Service Autonomy: Each service can discover and deploy itself independently
- Comprehensive Validation: Network, authentication, configuration, and endpoint validation
- š Security-by-Default: Automatic detection and prevention of insecure configurations
- š”ļø Production Security: Environment-specific security requirements and validation
- š Cryptographic Utilities: Secure key generation and secret management
- Production Testing: Health checks, authentication flows, performance monitoring
- Audit & Compliance: Detailed deployment logging and reporting
- š„ Customer Configuration Management: Multi-environment customer isolation and management
- šļø Template-Based Onboarding: Automated customer setup with reusable configuration templates
- š Framework Integration: Seamless integration with existing domain and feature flag systems
- š TypeScript First: Complete type safety with comprehensive type definitions and IDE support
- ā” Performance Optimized: Intelligent caching system for schemas, SQL queries, and validation results
- š Advanced Data Operations: Enhanced CRUD with relationships, advanced pagination, and query optimization
ļæ½ For Developers
If you're building services with the Lego Framework, see our comprehensive Developer Guide for:
- Installation and setup instructions
- Service creation and configuration
- Best practices for using public APIs
- Deployment patterns (embedding logic, not calling internal commands)
- Troubleshooting and common issues
š TypeScript Support
The Lego Framework provides comprehensive TypeScript support with 500+ lines of type definitions for complete type safety and enhanced developer experience.
$3
`typescript
// types/index.d.ts provides complete type coverage
import {
SchemaManager,
GenericDataService,
EnhancedRouter,
CustomerConfigurationManager
} from '@tamyla/lego-framework';
// Full IntelliSense and type checking
const schemaManager = new SchemaManager();
const service = new GenericDataService(d1Client, 'users');
`
$3
- Complete API Coverage: Every exported function and class is fully typed
- Advanced Generic Types: Complex data structures with proper generic constraints
- Validation Types: Type-safe schema definitions and validation results
- Cache Types: Typed caching interfaces with TTL and statistics
- Security Types: Comprehensive security validation and key generation types
- IDE Integration: Full IntelliSense, auto-completion, and refactoring support
> Important: The commands below are for framework development and internal use. External developers should embed deployment logic in their services rather than calling these scripts directly.
ļæ½š Working Commands
$3
`bash
Interactive domain deployment (Recommended)
node bin/deployment/enterprise-deploy.js deploy --interactive
Direct domain deployment
node bin/deployment/enterprise-deploy.js deploy data-service.greatidude.com
Deployment with custom validation level
node bin/deployment/enterprise-deploy.js deploy --interactive --validation comprehensive
Dry run deployment
node bin/deployment/enterprise-deploy.js deploy --interactive --dry-run
Skip production tests
node bin/deployment/enterprise-deploy.js deploy --interactive --no-tests
`
$3
`bash
Validate configuration security before deployment
npx lego-security validate customer production
Generate cryptographically secure keys
npx lego-security generate-key jwt 64
npx lego-security generate-key api content-skimmer
Deploy with automatic security validation
npx lego-security deploy customer production --dry-run
Check deployment readiness
npx lego-security check-readiness customer production
`
$3
`bash
Create new customer configuration from templates
npm run customer-config create-customer mycompany mycompany.com
List all configured customers
npm run customer-config list
Show effective configuration for customer/environment
npm run customer-config show mycompany production
Validate customer configuration structure
npm run customer-config validate
Get deployment command for customer
npm run customer-config deploy-command mycompany staging
`
$3
`bash
List available domains
node bin/deployment/enterprise-deploy.js list
Discover domain configuration
node bin/deployment/enterprise-deploy.js discover data-service.greatidude.com
Validate domain setup
node bin/deployment/enterprise-deploy.js validate data-service.greatidude.com
`
$3
`bash
Deploy multiple domains
node bin/deployment/enterprise-deploy.js deploy-multi domain1.com domain2.com
Deploy entire portfolio
node bin/deployment/enterprise-deploy.js deploy-portfolio
`
š§ Environment Requirements
$3
`bash
Required
Node.js >= 18.0.0
npm >= 9.0.0
npx (comes with npm)
wrangler >= 3.0.0
Verify installation
node --version
npm --version
npx wrangler --version
`
$3
1. Cloudflare Account: Active account with API access
2. API Token: Token with permissions:
- Zone:Read (for domain discovery)
- Zone Resources:Edit (for worker deployment)
- Account:Read (optional, for enhanced features)
- Cloudflare D1:Edit (optional, for database discovery)
3. Domain Configuration: Domains should be added to Cloudflare zones
$3
`
services/
āāā data-service/ # Service directory
ā āāā wrangler.toml # Cloudflare configuration
ā āāā package.json # Service dependencies
ā āāā src/
ā āāā config/domains.js # Domain configuration
ā āāā worker/index.js # Worker entry point
`
š Quick Start
$3
`bash
Clone the framework
git clone
cd lego-framework
Install dependencies
npm install
Ensure wrangler is available
npx wrangler --version
`
$3
`bash
Login to Cloudflare (first time only)
npx wrangler auth login
Or set API token directly (will be prompted automatically)
The system will securely store your token with encryption
`
$3
`bash
Interactive deployment (recommended for first time)
node bin/deployment/enterprise-deploy.js deploy --interactive
The system will:
1. Discover available services
2. Let you select a domain
3. Validate Cloudflare setup
4. Deploy the worker
5. Run production tests
6. Generate audit reports
`
$3
The deployment will output the worker URL. Visit it to confirm it's working:
`
ā
Deployment successful: https://your-service.your-domain.com
`
Project Structure
`
lego-framework/
āāā bin/ # Executable scripts and CLI tools
ā āāā service-management/ # Service creation and initialization
ā āāā deployment/ # Enterprise deployment tools
ā āāā database/ # Database management tools
ā āāā portfolio/ # Multi-service portfolio management
ā āāā shared/ # Shared utility modules
ā āāā config/ # Configuration management tools
ā āāā customer-cli.js # Customer configuration CLI
āāā scripts/ # PowerShell scripts and utilities
ā āāā service-management/ # Service setup scripts
ā āāā deployment/ # Deployment scripts
ā āāā testing/ # Testing utilities
ā āāā utilities/ # General utilities
āāā services/ # Generated services directory
ā āāā my-api-service/ # Individual service directories
ā āāā auth-service/ # Auto-organized by init-service
ā āāā data-service/ # Each with complete Cloudflare setup
āāā docs/ # Documentation
ā āāā analysis/ # Development analysis and demos
ā āāā api/ # API documentation
ā āāā examples/ # Usage examples
ā āāā guides/ # User guides
āāā test/ # Test suite
ā āāā integration/ # Integration tests
āāā src/ # Framework source code
ā āāā config/ # Configuration management
ā āāā customers.js # Customer configuration manager
ā āāā domains.js # Domain configuration system
ā āāā features.js # Feature flag system
āāā templates/ # Service templates
āāā config-templates/ # Configuration templates
āāā config/ # Framework configuration
āāā customers/ # Customer configuration templates
āāā template/ # Reusable customer config templates
`
Enterprise Deployment & Orchestration
The Lego Framework now includes comprehensive enterprise-grade deployment and orchestration capabilities, extracted from production systems and made reusable across all services.
$3
`javascript
import { MultiDomainOrchestrator, CrossDomainCoordinator } from '@tamyla/lego-framework/orchestration';
// Multi-domain deployment orchestration
const orchestrator = new MultiDomainOrchestrator({
domains: ['api', 'auth', 'data'],
environment: 'production',
parallelDeployments: 3
});
// Cross-domain coordination for complex deployments
const coordinator = new CrossDomainCoordinator({
portfolioName: 'enterprise-suite',
maxConcurrentDeployments: 5,
enableDependencyResolution: true
});
`
$3
`javascript
import { DeploymentValidator, RollbackManager, ProductionTester, DeploymentAuditor } from '@tamyla/lego-framework/deployment';
// Pre-deployment validation
const validator = new DeploymentValidator();
await validator.validateDeployment(deploymentConfig);
// Production testing suite
const tester = new ProductionTester();
await tester.runProductionTests(deploymentId);
// Rollback management
const rollback = new RollbackManager();
await rollback.createRollbackPoint(deploymentId);
// Comprehensive audit logging
const auditor = new DeploymentAuditor();
auditor.logDeployment(deploymentId, 'started', { domains: ['api', 'auth'] });
`
$3
`javascript
import { DatabaseOrchestrator } from '@tamyla/lego-framework/database';
// Multi-environment database management
const dbOrchestrator = new DatabaseOrchestrator({
projectRoot: './',
dryRun: false
});
// Run migrations across environments
await dbOrchestrator.runMigrations('production');
await dbOrchestrator.createBackup('production');
`
$3
`javascript
import { DomainDiscovery } from '@tamyla/lego-framework/config/discovery';
// Runtime domain discovery and configuration
const discovery = new DomainDiscovery({
apiToken: process.env.CLOUDFLARE_API_TOKEN
});
// Discover and cache domain configurations
await discovery.discoverDomains();
const config = await discovery.getDomainConfig('my-domain');
`
$3
`javascript
import { CustomerConfigurationManager } from '@tamyla/lego-framework/config';
// Framework-mode customer management (uses mock values for testing)
const customerManager = new CustomerConfigurationManager();
// Create customer configuration from templates
await customerManager.createCustomer('acmecorp', 'acmecorp.com', {
skipValidation: true,
isFrameworkMode: true
});
// Show effective configuration
const config = customerManager.showConfig('acmecorp', 'production');
// Validate customer configurations
const validation = await customerManager.validateConfigs();
// Get deployment commands
const deployCmd = customerManager.getDeployCommand('acmecorp', 'staging');
`
$3
`javascript
import { EnhancedSecretManager, ConfigurationCacheManager, askUser, askYesNo } from '@tamyla/lego-framework/utils/deployment';
// Advanced secret management
const secretManager = new EnhancedSecretManager();
await secretManager.generateSecrets(['database', 'api-keys']);
// Configuration caching
const cache = new ConfigurationCacheManager();
await cache.cacheConfiguration(deploymentId, config);
// Interactive prompts for deployment scripts
const environment = await askChoice('Select environment:', ['staging', 'production']);
const confirmed = await askYesNo('Deploy to production?');
`
Enterprise CLI Tools
The Lego Framework now includes powerful command-line tools for enterprise deployment and portfolio management.
$3
`bash
npm install -g @tamyla/lego-framework
or
npx @tamyla/lego-framework --help
`
$3
#### lego-deploy - Enterprise Deployment CLI
Advanced deployment system with multi-domain orchestration, validation, and rollback capabilities.
`bash
Deploy a single domain
npx lego-deploy deploy my-domain --environment production
Deploy multiple domains with coordination
npx lego-deploy deploy-multi api auth data --parallel
Validate deployment readiness
npx lego-deploy validate my-domain
Run production tests
npx lego-deploy test my-domain
Rollback deployment
npx lego-deploy rollback my-domain
`
#### lego-master-deploy - Master Deployment Orchestrator
Comprehensive deployment orchestrator with enterprise features and portfolio management.
`bash
Deploy with full orchestration
npx lego-master-deploy orchestrate --domains api,auth,data
Run pre-deployment validation
npx lego-master-deploy validate --portfolio
Monitor deployment progress
npx lego-master-deploy monitor
`
#### lego-portfolio - Portfolio Management CLI
Multi-domain portfolio operations with bulk management and analytics.
`bash
Initialize portfolio
npx lego-portfolio init --portfolio-name my-enterprise
Discover all domains
npx lego-portfolio discover
Deploy entire portfolio
npx lego-portfolio deploy
Get portfolio health status
npx lego-portfolio health
Generate portfolio analytics
npx lego-portfolio analytics
`
#### lego-db - Database Management CLI
Enterprise database operations across multiple environments.
`bash
Run migrations for domain
npx lego-db migrate my-domain --environment production
Synchronize schemas across portfolio
npx lego-db sync --portfolio
Create backups
npx lego-db backup my-domain
`
#### lego-secrets - Secret Generation Utility
Cryptographically secure secret generation for production deployments.
`bash
Generate secrets for domain
npx lego-secrets --domain my-domain --environment production
Generate specific secret types
npx lego-secrets --types database,api-keys,jwt --persist
`
Quick Start
$3
`bash
npm install @tamyla/lego-framework
`
$3
`bash
npx create-lego-service my-new-service --type data-service
`
$3
`javascript
import { initializeService, createFeatureGuard, FeatureFlagManager } from '@tamyla/lego-framework';
export default {
async fetch(request, env, ctx) {
// Initialize service with domain context
const service = initializeService(env);
// Feature-guarded endpoints
if (request.url.includes('/premium')) {
return createFeatureGuard('premiumFeatures')(
handlePremiumRequest
)(request, env, ctx);
}
return handleRequest(request, env, ctx);
}
};
`
Deployment Workflow
The Lego Framework provides a clear setup-first, deploy-second workflow to avoid configuration dependency issues.
$3
Before deployment, initialize your service to generate required configuration files:
`bash
Initialize a new service with configuration generation
npx lego-init my-service --type api-gateway --env development
This creates:
- wrangler.toml (Cloudflare Workers config)
- src/config/domains.js (Domain configuration)
- Validates environment variables
- Prepares for deployment
`
$3
Once initialized, deploy using the enterprise deployment system:
`bash
Deploy to production
npx lego-deploy my-service --env production
Multi-domain deployment
npx lego-deploy-multi api auth data --env staging
Portfolio deployment (all domains)
npx lego-deploy-portfolio --env production
`
$3
Set these before deployment:
`bash
export CLOUDFLARE_ACCOUNT_ID="your_account_id"
export CLOUDFLARE_ZONE_ID="your_zone_id"
export CLOUDFLARE_API_TOKEN="your_api_token"
`
$3
1. Init ā Generate configurations and validate setup
2. Deploy ā Deploy with enterprise orchestration
3. Monitor ā Use built-in auditing and rollback features
This ensures configurations exist before deployment attempts, eliminating the "expecting wrangler.toml readily available" issue for first-time deployments.
Architecture
$3
1. Domain Configuration: JSON-based configuration with validation
2. Feature Flags: Runtime feature management
3. Worker Integration: Service initialization helpers
4. Deployment Framework: Automated deployment scripts
5. Service Registry: Cross-service communication
$3
`
services/my-service/
āāā src/
ā āāā config/
ā ā āāā domains.js # Service-specific domain configs
ā ā āāā features.js # Service feature definitions
ā āāā worker/
ā ā āāā index.js # Main worker handler
ā āāā routes/
āāā scripts/
ā āāā deploy.ps1 # Deployment script
ā āāā setup.ps1 # Setup script
āāā package.json
āāā wrangler.toml
`
Configuration
$3
`javascript
// config/domains.js
import { createDomainConfigSchema } from '@tamyla/lego-framework';
export const domains = {
'my-domain': {
...createDomainConfigSchema(),
name: 'my-domain',
displayName: 'My Domain',
accountId: 'your-cloudflare-account-id',
zoneId: 'your-zone-id',
domains: {
production: 'api.myapp.com',
staging: 'staging-api.myapp.com'
},
features: {
premiumFeatures: true,
analytics: false
}
}
};
`
$3
`javascript
// config/features.js
export const FEATURES = {
PREMIUM_FEATURES: 'premiumFeatures',
ANALYTICS: 'analytics',
FILE_STORAGE: 'fileStorage'
};
`
Deployment
$3
`powershell
Deploy to staging
.\scripts\deploy.ps1 -DomainName my-domain -Environment staging
Deploy to production
.\scripts\deploy.ps1 -DomainName my-domain -Environment production
`
$3
`powershell
Run interactive setup
.\scripts\setup.ps1
`
ļæ½ Troubleshooting
$3
#### "Service directory not found for domain"
`bash
Problem: No service exists for the domain
Solution: Check available services
node bin/deployment/enterprise-deploy.js list
Or create a new service (if service creation tools are available)
Ensure the service has proper domain configuration in src/config/domains.js
`
#### "API token required for domain verification"
`bash
Problem: No Cloudflare authentication
Solution: The system will automatically prompt for API token
Or manually set up wrangler auth:
npx wrangler auth login
`
#### "D1 database discovery requires additional permissions"
`bash
This is informational only - deployment continues successfully
To enable D1 discovery, update your API token with:
- Account:Read permissions
- Cloudflare D1:Edit permissions
`
#### Production tests failing with ENOTFOUND
`bash
This is normal for new deployments during DNS propagation
The system waits 10 seconds but some domains may need longer
Tests failures don't prevent deployment success
`
#### "npx command not found" on Windows
`bash
Problem: Command configuration for cross-platform compatibility
Solution: The system uses validation-config.json for command mapping
Ensure npx is in your PATH or update the config file
`
$3
`bash
Run with verbose logging
node bin/deployment/enterprise-deploy.js deploy --interactive --validation comprehensive
Check specific domain configuration
node bin/deployment/enterprise-deploy.js discover your-domain.com
`
ļæ½š Development Insights & Lessons Learned
$3
#### 1. Interactive vs Hardcoded Parameters ā
- Problem: Original system required domain as command argument
- Solution: Added --interactive flag for domain selection from discovered services
- Impact: Much better UX, reduces deployment errors
#### 2. Cross-Platform Command Compatibility ā
- Problem: Hardcoded commands failed on different platforms (Windows vs Linux)
- Solution: Configurable command system via validation-config.json
- Impact: Seamless cross-platform operation
#### 3. API Token Management ā
- Problem: OAuth authentication insufficient for API operations
- Solution: Secure API token storage with AES-256-CBC encryption
- Impact: Reliable authentication with automated prompting
#### 4. Service Discovery Intelligence ā
- Problem: Expected exact directory names matching domains
- Solution: Smart discovery by checking domains.js configuration files
- Impact: Flexible service organization and deployment
#### 5. Real vs Mock Deployments ā
- Problem: Mock deployments provided false success with undefined URLs
- Solution: Actual wrangler execution with URL extraction
- Impact: Real deployment validation and working services
$3
#### Graceful Error Handling
`javascript
// D1 database discovery with permission graceful degradation
if (error.message.includes('401') || error.message.includes('Unauthorized')) {
console.log(ā¹ļø D1 database discovery requires additional API token permissions);
console.log(š” To enable D1 discovery, ensure your API token has 'Account:Read' or 'Cloudflare D1:Edit' permissions);
} else {
console.log(ā ļø D1 database discovery failed: ${error.message});
}
`
#### Smart Service Directory Discovery
`javascript
// Find service directory by domain configuration rather than exact name match
for (const serviceDir of serviceDirs) {
const domainsPath = join(servicesDir, serviceDir, 'src', 'config', 'domains.js');
if (existsSync(domainsPath)) {
const domainsContent = await fs.readFile(domainsPath, 'utf8');
if (domainsContent.includes(domain)) {
servicePath = join(servicesDir, serviceDir);
break;
}
}
}
`
#### Production Test Resilience
`javascript
// Wait for deployment propagation before running tests
if (options.tests !== false && deploymentResult.url) {
this.logOutput('ā³ Waiting for deployment to propagate...', 'info');
await new Promise(resolve => setTimeout(resolve, 10000)); // 10 second delay
const testResult = await this.modules.productionTester.runProductionTests(deploymentUrl, options);
}
`
š® Future Improvements
$3
Goal: Each service becomes completely autonomous
#### Service-Level Integration
`javascript
// Each service gets its own deployment module
service-repo/
āāā deployment/
ā āāā deploy.js # Service-specific deployment
ā āāā config.js # Service deployment config
ā āāā validators.js # Service validation logic
āāā src/config/domains.js # Multi-domain configuration
āāā package.json # Includes lego-framework as dependency
`
#### Reusable Component Library
`javascript
import {
DomainDiscovery,
CloudflareManager,
DeploymentValidator,
ProductionTester
} from '@tamyla/lego-framework';
// Each service imports only what it needs
const discovery = new DomainDiscovery({ domain: 'my-service.domain.com' });
await discovery.validateCloudflareSetup();
`
$3
- Dependency Resolution: Services declare dependencies on other services
- Blue-Green Deployments: Zero-downtime deployment patterns
- Canary Releases: Gradual rollout with automatic monitoring
- Multi-Region Deployment: Global service distribution
$3
- Service Mesh Integration: Inter-service communication patterns
- Centralized Monitoring: Unified observability across all services
- Policy Management: Governance and compliance automation
- Cost Optimization: Resource usage monitoring and optimization
$3
This framework currently serves as:
1. Development Environment: Understanding deployment workflows and requirements
2. Component Testing: Validating integration patterns and error handling
3. Template Generation: Creating reusable patterns for service codebases
4. Integration Standards: Defining how autonomous services should operate
Next Evolution: Extract successful patterns into lightweight libraries that individual services can import and use independently.
š Recent Major Enhancement: Customer Configuration Management
The Lego Framework has successfully incorporated enterprise-grade customer configuration management capabilities, transforming it from a single-service framework into a multi-customer, multi-environment enterprise platform.
$3
#### š„ Customer Isolation & Management
- Multi-customer support with isolated configuration namespaces
- Template-based customer onboarding from reusable configuration templates
- Customer registry with automatic domain registration
- Framework-safe design using mock values for development/testing
#### šļø Template-Driven Architecture
- Environment-specific templates (development.env.template, staging.env.template, production.env.template)
- Variable substitution with customer-specific placeholders ({{CUSTOMER_NAME}}, {{DOMAIN}}, etc.)
- Automated configuration generation from templates to production-ready configs
- Template inheritance supporting cross-customer and cross-environment patterns
#### š Framework Integration
- Domain system integration - customers automatically registered as domains
- Feature flag integration - customer-specific features managed through existing system
- Validation framework integration - customer configs validated using existing patterns
- CLI tool integration - customer management accessible via npm run customer-config
#### š ļø Developer Experience
- CLI tools: create-customer, show, validate, list, deploy-command
- Programmatic API: Full TypeScript/JavaScript API for customer management
- Framework mode: Mock-friendly for development without real infrastructure
- Service migration path: Generated configs can be copied to service repositories
$3
#### For Framework Users
- Zero breaking changes - all existing functionality preserved
- Enhanced capabilities - framework now supports enterprise customer scenarios
- Better testing - customer scenarios can be tested in framework environment
- Migration ready - smooth path from framework testing to service implementation
#### For Service Developers
- Customer-ready services - framework provides patterns for multi-customer support
- Automated onboarding - customer setup becomes template-driven process
- Consistent patterns - same customer management approach across all services
- Reduced duplication - shared customer configuration logic
#### For Enterprise Teams
- Multi-customer support - single framework handles multiple customer deployments
- Environment isolation - separate configs for dev/staging/production per customer
- Scalable architecture - customer management scales with business growth
- Governance & compliance - centralized customer configuration management
$3
#### Clean Architecture
- Separation of concerns: Framework provides tools, services manage customer data
- Mock-friendly: Framework mode uses placeholders, service mode uses real values
- Composable: Customer management integrates with existing domain/feature systems
- Testable: Full test coverage without requiring real Cloudflare infrastructure
#### Developer Workflow
`bash
Framework development/testing
npm run customer-config create-customer testcorp testcorp.com
npm run customer-config show testcorp production
Service implementation (copy generated configs)
cp config/customers/testcorp/* my-service/src/config/customers/testcorp/
Then customize for production infrastructure
`
#### API Design
`javascript
// Framework mode (mock values)
const customerManager = new CustomerConfigurationManager();
await customerManager.createCustomer('acmecorp', 'acmecorp.com', {
skipValidation: true,
isFrameworkMode: true
});
// Service mode (real infrastructure)
const customerManager = new CustomerConfigurationManager();
await customerManager.createCustomer('acmecorp', 'acmecorp.com', {
accountId: 'real-cloudflare-account-id',
zoneId: 'real-cloudflare-zone-id'
});
`
$3
The Lego Framework has successfully evolved from a single-service deployment framework into a comprehensive enterprise platform that supports:
- ā
Multi-service orchestration (existing)
- ā
Multi-environment deployment (existing)
- ā
Multi-customer configuration (newly added)
- ā
Enterprise-grade security (existing)
- ā
Developer experience (enhanced)
This enhancement maintains backward compatibility while significantly expanding the framework's capabilities for enterprise scenarios. The customer configuration management system is now a core, production-ready feature that enables the framework to support complex, multi-customer enterprise deployments.
The Lego Framework is now ready to "snap together" not just services, but entire customer ecosystems! š§±ā”ļøš¢
Scripts and Tools
The Lego Framework includes a comprehensive set of scripts and command-line tools, organized by functionality.
$3
`
scripts/
āāā service-management/ # Service creation and setup
āāā deployment/ # Deployment scripts
āāā testing/ # Testing utilities
āāā utilities/ # General utilities
bin/
āāā service-management/ # Service creation tools
āāā deployment/ # Enterprise deployment CLI
āāā database/ # Database management
āāā portfolio/ # Multi-service management
āāā shared/ # Shared utility modules
`
$3
Create services with auto-generated configurations:
`bash
Initialize service with multi-domain support
node bin/service-management/init-service.js my-service \
--type api-gateway \
--domains "api.example.com:account1:zone1,staging.example.com:account2:zone2"
Create service from template
node bin/service-management/create-service.js my-service --type data-service
`
Interactive setup:
`powershell
.\scripts\service-management\setup-interactive.ps1 -ServiceName my-service
`
$3
Enterprise deployment:
`bash
node bin/deployment/enterprise-deploy.js deploy --service my-service --environment production
`
Domain-specific deployment:
`powershell
.\scripts\deployment\deploy-domain.ps1 -DomainName api.example.com -Environment production
`
$3
Run tests:
`powershell
.\scripts\testing\test.ps1
.\scripts\testing\test-first.ps1 -ServiceName my-service
`
$3
Database operations:
`bash
node bin/database/enterprise-db-manager.js migrate --service my-service
node bin/database/enterprise-db-manager.js backup --database my-db
`
$3
Multi-service orchestration:
`bash
node bin/portfolio/portfolio-manager.js create --name my-portfolio
node bin/portfolio/portfolio-manager.js deploy --portfolio my-portfolio --environment production
`
Development
$3
`bash
npm run build
`
$3
`bash
npm test
`
$3
`bash
npm run lint
``