@bleujs/core v1.1.0
.js/core
- Bleu.js is a Rule-based AI framework designed to provide pinpoint solutions to various problems. It's is a JavaScript framework built to tackle the various coding challenges developers face.
Features
- Advanced debugging
- Automates dependency management
- Ensure Code Quality: Tools to ensure the highest code quality
- Generate Eggs: Automatically generate code snippets
- Provides tools to maintain code quality without adding extra complexity
- Real-time optimization suggestions
- Streamlines collaboration
- Support for multiple programming languages
- Manage Dependencies: Handle project dependencies efficiently
Prerequisites
Install the bleujs package using pnpm:
pnpm add bleujsbleujs startor
pnpm install bleujs@latestpnpm run startRetrieve Package Information
pnpm info bleujspnpm list | grep bleujsDirectory Structure
- core-engine: Contains the main logic for code generation, optimization, and debugging.
- language-plugins: Modules for different programming languages.
- javascript: JavaScript-specific tools.
- python: Python-specific tools.
- collaboration-tools: Tools for code review, issue tracking, and project management.
- dependency-management: Tools for monitoring and managing dependencies.
- code-quality-assurance: Tools for continuous code quality checks and analysis.
- eggs-generator: Tools for generating code snippets and optimization suggestions by HenFarm.js, the framework built by Helloblue.
- docker: Docker configuration files.
Features
Core Engine
- Efficient CPU core utilization through worker (Agent) processes
- Automatic worker restart for high availability
- Dynamic code generation and template management
- Enhanced logging with winston integration
- Comprehensive metrics tracking
- WebSocket connection management
- Request rate limiting
- Health monitoring
- Graceful shutdown handling
Generate a UsersController with Bleu.js
Bleu.js, uses the HenFarm.js framework by Helloblue, Inc. for generating code snippets, referred to as "eggs." It's an integral part of Bleu.js, providing the functionality to automatically generate new code snippets to help improve efficiency and solve coding problems.
After installing Bleu.js via pnpm, you can generate a UsersController dynamically using the Bleu.js API.
Ensure you have a Valid JWT Token
Generate a valid JWT Token
openssl rand -base64 32Replace YOUR_JWT_TOKEN with your valid JWT, and test it with this cURL in another terminal
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-users-controller" \
-H "Authorization: Bearer YOUR_VALID_JWT" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "UsersController",
"route": "/api/users",
"methods": ["GET", "POST", "PUT", "DELETE"],
"security": {
"auth": ["jwt"],
"roles": ["admin", "user"]
}
}
}'Limbda, Bleujs REST API cURL Tests Package
A complete set of cURL requests for generating services, models, APIs, event-driven services, and advanced system configurations.
Starting the Server
cd core-enginepnpm startIn another terminal start cURL tests:
Deep Health Check
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "HealthCheckController",
"route": "/api/health/deep",
"methods": ["GET"],
"logic": {
"GET": {
"description": "Performs a deep health check on services",
"implementation": "async function checkHealth() { return { database: 'OK', cache: 'OK', queue: 'OK' }; }"
}
}
}
}'Complex Services
Authentication Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-auth-service" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"type": "service",
"parameters": {
"name": "AuthenticationService",
"methods": [
"login", "logout", "refreshToken", "validateSession",
"changePassword", "resetPassword", "generateTwoFactorCode",
"verifyTwoFactorCode", "revokeToken", "updateProfile"
],
"security": {
"auth": ["jwt", "oauth2"],
"roles": ["admin", "user"]
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"errorHandling": true,
"caching": {
"enabled": true,
"type": "redis",
"expiration": 900
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 5000
},
"resilience": {
"circuitBreaker": {
"failureThreshold": 3,
"resetTimeout": 20000
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
}
},
"parallelExecution": {
"enabled": true,
"workerThreads": 5
},
"responseFormat": "JSON",
"versioning": "2.0.0"
}
}' | jq '.'Extreme Name Length
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-long-name" \
-d "{
\"type\": \"service\",
\"parameters\": {
\"name\": \"$(printf 'a%.0s' {1..1000})Service\",
\"methods\": [\"method1\"]
}
}" | jq '.'Generate Microservice with Advanced Features
Payment Service
Generate Payment Service with Advanced Features
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-payment-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "PaymentService",
"methods": [
"processPayment",
"validateCard",
"calculateFees",
"generateInvoice",
"refundTransaction",
"getTransactionHistory"
],
"logging": true,
"errorHandling": true,
"authentication": "JWT",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 500
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5,
"resetTimeout": 60000
},
"retryPolicy": {
"enabled": true,
"maxAttempts": 3,
"backoffStrategy": "exponential"
},
"observability": {
"logs": "enabled",
"monitoring": "enabled",
"alerts": "enabled"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate REST API with Authentication
Payments Controller
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-payments-controller" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "PaymentsController",
"route": "/api/payments",
"methods": ["GET", "POST", "PUT", "DELETE"],
"security": {
"auth": ["jwt", "apiKey"],
"roles": ["admin", "operator"],
"rateLimit": {
"enabled": true,
"window": "1m",
"maxRequests": 100
},
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET", "POST", "PUT", "DELETE"]
},
"csrfProtection": true,
"inputSanitization": true
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": true,
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate Migration
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-migration" \
-H "Accept: application/json" \
-d '{
"type": "migration",
"parameters": {
"name": "AddPaymentFields",
"database": "postgresql",
"changes": [
{
"type": "addColumn",
"table": "payments",
"column": "status",
"dataType": "VARCHAR(50)",
"default": "pending",
"constraints": ["NOT NULL"]
},
{
"type": "createIndex",
"table": "payments",
"columns": ["status"],
"unique": false
}
],
"rollback": {
"enabled": true,
"steps": [
{
"type": "dropColumn",
"table": "payments",
"column": "status"
},
{
"type": "dropIndex",
"table": "payments",
"columns": ["status"]
}
]
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
}
}
}'Generate Deployment Config
Payment Deployment Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-payment-deployment" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "PaymentDeploymentService",
"methods": [
"deployToKubernetes",
"scaleReplicas",
"updateConfig",
"restartService"
],
"deploymentConfig": {
"platform": "kubernetes",
"components": [
"deployment",
"service",
"ingress",
"configmap",
"secrets"
],
"resources": {
"cpu": "500m",
"memory": "512Mi",
"replicas": 3
},
"autoscaling": {
"enabled": true,
"minReplicas": 2,
"maxReplicas": 10,
"cpuThreshold": 80
},
"configmap": {
"enabled": true,
"variables": {
"NODE_ENV": "production",
"LOG_LEVEL": "info"
}
},
"secrets": {
"enabled": true,
"values": {
"DATABASE_URL": "encrypted_value",
"API_KEY": "encrypted_value"
}
},
"ingress": {
"enabled": true,
"host": "api.example.com",
"tls": true
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"middleware": [
"validateRequest",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'CRUD API Service Template
Generate Service Template
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-user-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": [
"findAll",
"findById",
"create",
"update",
"delete",
"search"
],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"strategy": "standard"
},
"authentication": {
"enabled": true,
"strategy": "JWT"
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"databaseIntegration": {
"enabled": true,
"type": "MongoDB",
"schemaValidation": true
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate Code Templates
Generate Model
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-model" \
-H "Accept: application/json" \
-d '{
"type": "model",
"parameters": {
"name": "OrderModel",
"fields": [
{"name": "id", "type": "UUID", "primaryKey": true, "autoGenerate": true},
{"name": "userId", "type": "UUID", "references": "UserModel"},
{"name": "amount", "type": "DECIMAL", "precision": 10, "scale": 2, "nullable": false},
{"name": "currency", "type": "STRING", "default": "USD", "maxLength": 3},
{"name": "status", "type": "STRING", "default": "pending", "enum": ["pending", "completed", "failed"]},
{"name": "createdAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP"},
{"name": "updatedAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP", "onUpdate": "CURRENT_TIMESTAMP"}
],
"indexes": [
{"columns": ["status"], "unique": false},
{"columns": ["userId", "status"], "unique": false}
],
"methods": [
"findByUserId",
"updateStatus",
"calculateTotal",
"deletePayment"
],
"relations": [
{"type": "belongsTo", "target": "UserModel", "foreignKey": "userId"}
],
"logging": true,
"errorHandling": true,
"caching": "redis",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 200
},
"schemaValidation": true,
"databaseIntegration": "MongoDB",
"versioning": "1.1.0"
}
}'Generate Service Class
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": [
"findAll",
"findById",
"create",
"update",
"delete",
"validateBeforeSave"
],
"logging": true,
"errorHandling": true,
"authentication": "JWT",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 500
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"versioning": "1.1.0",
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser"
],
"responseFormat": "JSON",
"authorizationRoles": ["admin", "user", "guest"]
}
}'Generate Repository
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-repository" \
-H "Accept: application/json" \
-d '{
"type": "repository",
"parameters": {
"name": "OrderRepository",
"methods": [
"findById",
"findAll",
"findByCategory",
"createBulk",
"updateMany",
"softDelete"
],
"databaseIntegration": "MongoDB",
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"logging": true,
"errorHandling": true,
"pagination": true,
"schemaValidation": true
}
}'Advanced Usage
Event Sourcing Pattern
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-event-sourcing" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "EventSourcingEngine",
"methods": [
"appendToEventStream",
"reconstructAggregateState",
"handleEventReplay",
"manageEventStore",
"versionSnapshot"
],
"databaseIntegration": "MongoDB",
"eventPersistence": {
"enabled": true,
"strategy": "eventStore",
"retentionPolicy": "7_days"
},
"distributedTracing": true,
"logging": true,
"errorHandling": true,
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 500
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600
},
"versioning": "1.1.0"
}
}'Expected API Response
{
"success": true,
"code": "class EventSourcingEngine {...}",
"metadata": {
"requestId": "test-event-sourcing",
"generatedAt": "2025-02-16T11:45:30.123Z",
"duration": "1.54ms",
"engineVersion": "bleu.js v.1.1.0",
"type": "service",
"className": "EventSourcingEngine",
"methodCount": 5,
"nodeVersion": "v20.18.1",
"platform": "darwin"
}
}Controller generation
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-controller" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "UserController",
"route": "/api/users",
"methods": ["GET", "POST", "PUT", "DELETE"],
"security": {
"auth": ["jwt"],
"roles": ["admin", "user"],
"rateLimit": {
"window": "1m",
"max": 100
},
"csrfProtection": true,
"inputSanitization": true,
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET", "POST", "PUT", "DELETE"]
}
},
"logging": {
"enabled": true,
"level": "info"
},
"errorHandling": true,
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"responseFormat": "JSON",
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"versioning": "1.2.0"
}
}'Model generation
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-model" \
-H "Accept: application/json" \
-d '{
"type": "model",
"parameters": {
"name": "User",
"fields": [
{"name": "id", "type": "UUID", "primaryKey": true, "autoGenerate": true},
{"name": "username", "type": "STRING", "unique": true, "maxLength": 50},
{"name": "email", "type": "STRING", "unique": true, "validate": "email"},
{"name": "password", "type": "STRING", "hashing": "bcrypt"},
{"name": "role", "type": "STRING", "default": "user", "enum": ["user", "admin"]},
{"name": "createdAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP"},
{"name": "updatedAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP", "onUpdate": "CURRENT_TIMESTAMP"}
],
"indexes": [
{"columns": ["email"], "unique": true},
{"columns": ["username"], "unique": true}
],
"relations": [
{"type": "hasMany", "target": "Post", "foreignKey": "userId"}
],
"schemaValidation": true,
"encryption": {
"enabled": true,
"fields": ["password"]
},
"logging": true,
"versioning": "1.1.0",
"databaseIntegration": "MongoDB"
}
}'Expected API Response
{
"success": true,
"code": "class UserModel {...}",
"metadata": {
"requestId": "test-model",
"generatedAt": "2025-02-16T12:30:45.987Z",
"duration": "1.45ms",
"engineVersion": "bleu.js v.1.1.0",
"type": "model",
"className": "User",
"fieldCount": 7,
"nodeVersion": "v20.18.1",
"platform": "darwin"
}
}Service generation
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": [
"findAll",
"findById",
"create",
"update",
"delete"
],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"strategy": "global",
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
}
},
"authentication": {
"type": "JWT",
"requiredRoles": ["admin", "user", "guest"]
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600
},
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5,
"resetTimeout": 60000
},
"versioning": "1.1.0",
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON"
}
}'API endpoint generation
Controller Generation
HelloController with Advanced Features
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-hello-controller" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "HelloController",
"route": "/hello",
"methods": ["GET"],
"security": {
"auth": ["none"],
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 500
},
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET"]
}
},
"caching": {
"enabled": true,
"type": "memory",
"expiration": 300
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"errorHandling": true,
"responseFormat": "JSON",
"middleware": ["validateRequest", "rateLimit", "monitorPerformance"],
"versioning": "1.2.0"
}
}'Service Generation
Generate Service Class
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-service" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": [
"findAll",
"findOne",
"create",
"update",
"delete",
"validateBeforeSave"
],
"logging": true,
"errorHandling": true,
"caching": "redis",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 100
}
}
}'UserService with Security & Caching
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-user-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": ["findAll", "findById", "create", "update", "delete"],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"strategy": "global",
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
}
},
"authentication": {
"type": "JWT",
"requiredRoles": ["admin", "user"],
"enforceSessionExpiration": true
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600,
"invalidateOnUpdate": true
},
"databaseIntegration": {
"type": "MongoDB",
"connectionPoolSize": 20
},
"schemaValidation": true,
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5,
"resetTimeout": 60000
},
"versioning": "1.2.0",
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON"
}
}'"/hello" with Enhanced Configuration
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-api-hello" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "api",
"parameters": {
"route": "/hello",
"message": "Hello World!",
"security": {
"auth": ["none"],
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 2000
},
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET"]
}
},
"responseFormat": "JSON",
"caching": {
"enabled": true,
"type": "memory",
"expiration": 300
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"responseValidation": {
"enabled": true,
"schema": {
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
}
},
"middleware": [
"validateRequest",
"rateLimit",
"logRequest",
"monitorPerformance"
],
"versioning": "1.2.0"
}
}'Generate Microservice with Advanced Features
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-payment-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "PaymentService",
"methods": [
"processPayment",
"validateCard",
"calculateFees",
"generateInvoice",
"refundTransaction",
"getTransactionHistory"
],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"strategy": "global",
"retryPolicy": {
"enabled": true,
"maxAttempts": 3,
"backoffStrategy": "exponential"
}
},
"authentication": {
"type": "JWT",
"requiredRoles": ["admin", "finance"]
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 5000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600,
"invalidateOnUpdate": true
},
"databaseIntegration": {
"type": "PostgreSQL",
"connectionPoolSize": 50
},
"schemaValidation": true,
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5,
"resetTimeout": 30000
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate REST API with Authentication
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-rest-api" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "api",
"parameters": {
"route": "/api/payments",
"security": {
"auth": ["jwt", "apiKey"],
"roles": ["admin", "operator"],
"rateLimit": {
"enabled": true,
"window": "1m",
"max": 100
},
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET", "POST", "PUT", "DELETE"]
}
},
"methods": ["GET", "POST", "PUT", "DELETE"],
"validation": {
"enabled": true,
"schema": {
"amount": { "type": "number", "minimum": 0 },
"currency": { "type": "string", "enum": ["USD", "EUR", "GBP"] },
"description": { "type": "string", "maxLength": 255, "optional": true }
}
},
"responseValidation": {
"enabled": true,
"schema": {
"success": { "type": "boolean" },
"message": { "type": "string" },
"data": { "type": "object", "optional": true }
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"openAPIDocumentation": {
"enabled": true,
"version": "3.0.0",
"title": "Payments API",
"description": "Handles all payment-related operations"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate Event-Driven Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-event-driven" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "NotificationService",
"events": [
"userRegistered",
"orderPlaced",
"paymentProcessed",
"orderShipped"
],
"integrations": [
"kafka",
"redis",
"elasticsearch"
],
"options": {
"retries": {
"enabled": true,
"maxAttempts": 5,
"backoffStrategy": "exponential"
},
"deadLetterQueue": {
"enabled": true,
"retentionPeriod": "7d"
},
"monitoring": {
"enabled": true,
"system": "Prometheus"
},
"schemaValidation": {
"enabled": true,
"schemas": {
"userRegistered": {
"type": "object",
"properties": {
"userId": { "type": "string" },
"email": { "type": "string", "format": "email" }
},
"required": ["userId", "email"]
},
"orderPlaced": {
"type": "object",
"properties": {
"orderId": { "type": "string" },
"totalAmount": { "type": "number", "minimum": 0 }
},
"required": ["orderId", "totalAmount"]
}
}
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"versioning": "1.2.0",
"middleware": [
"validateEvent",
"logRequest",
"monitorPerformance"
]
}
}'Generate GraphQL API
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-graphql-api" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserGraphQLService",
"methods": [
"getUser",
"listUsers",
"searchUsers",
"createUser",
"updateUser",
"deleteUser"
],
"graphqlSchema": {
"types": [
{
"name": "User",
"fields": {
"id": "ID!",
"name": "String!",
"email": "String!"
}
},
{
"name": "Order",
"fields": {
"id": "ID!",
"total": "Float!",
"items": "[String]"
}
}
],
"queries": [
{
"name": "getUser",
"params": { "id": "ID!" },
"returnType": "User"
},
{
"name": "listUsers",
"returnType": "[User]"
},
{
"name": "searchUsers",
"params": { "name": "String!" },
"returnType": "[User]"
}
],
"mutations": [
{
"name": "createUser",
"params": { "name": "String!", "email": "String!" },
"returnType": "User"
},
{
"name": "updateUser",
"params": { "id": "ID!", "name": "String", "email": "String" },
"returnType": "User"
},
{
"name": "deleteUser",
"params": { "id": "ID!" },
"returnType": "Boolean"
}
]
},
"authentication": {
"enabled": true,
"type": "JWT"
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"middleware": [
"validateRequest",
"authenticateUser",
"logRequest",
"monitorPerformance"
],
"responseFormat": "GraphQL",
"versioning": "1.2.0"
}
}'Request for Load Testing Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-load-test" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "LoadTestingService",
"methods": [
"simulateHighConcurrency",
"testErrorScenarios",
"simulateTimeouts"
],
"loadTestConfig": {
"users": 1000,
"duration": "5m",
"scenarios": [
"highConcurrency",
"errorScenarios",
"timeouts"
],
"metrics": {
"latency": true,
"throughput": true,
"errorRate": true
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"middleware": [
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate Documentation
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-api-docs" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "APIDocumentationService",
"methods": ["generateOpenAPI", "exportSchema", "serveSwaggerUI"],
"openAPIConfig": {
"version": "3.0.0",
"format": "openapi",
"info": {
"title": "Payment API",
"description": "Comprehensive API documentation for Payment Service",
"version": "1.0.0"
},
"servers": [
{ "url": "https://api.example.com/v1", "description": "Production Server" },
{ "url": "http://localhost:3001", "description": "Local Development Server" }
],
"sections": [
"overview",
"authentication",
"endpoints",
"schemas",
"examples"
],
"authentication": {
"enabled": true,
"type": ["JWT", "API Key"]
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"middleware": [
"validateRequest",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Generate Deployment Config
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-deployment-config" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "DeploymentConfigurationService",
"methods": ["generateKubernetesDeployment", "configureIngress", "manageSecrets"],
"kubernetesConfig": {
"platform": "kubernetes",
"components": [
"deployment",
"service",
"ingress",
"configmap",
"secrets"
],
"resources": {
"cpu": "500m",
"memory": "512Mi",
"replicas": 3
},
"autoscaling": {
"enabled": true,
"minReplicas": 2,
"maxReplicas": 10,
"cpuThreshold": 80
},
"configmap": {
"enabled": true,
"variables": {
"NODE_ENV": "production",
"LOG_LEVEL": "info"
}
},
"secrets": {
"enabled": true,
"values": {
"DATABASE_URL": "encrypted_value",
"API_KEY": "encrypted_value"
}
},
"ingress": {
"enabled": true,
"host": "api.example.com",
"tls": true
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"middleware": [
"validateRequest",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Get Metrics
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-db-model" \
-H "Accept: application/json" \
-d '{
"type": "model",
"parameters": {
"name": "PaymentModel",
"fields": [
{"name": "id", "type": "UUID", "primaryKey": true, "autoGenerate": true},
{"name": "userId", "type": "UUID", "references": "UserModel"},
{"name": "amount", "type": "DECIMAL", "precision": 10, "scale": 2, "nullable": false},
{"name": "currency", "type": "STRING", "default": "USD", "maxLength": 3},
{"name": "status", "type": "STRING", "default": "pending", "enum": ["pending", "completed", "failed"]},
{"name": "createdAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP"},
{"name": "updatedAt", "type": "DATETIME", "default": "CURRENT_TIMESTAMP", "onUpdate": "CURRENT_TIMESTAMP"}
],
"indexes": [
{"columns": ["status"], "unique": false},
{"columns": ["userId", "status"], "unique": false}
],
"methods": [
"findByUserId",
"updateStatus",
"calculateTotal",
"deletePayment"
],
"relations": [
{"type": "belongsTo", "target": "UserModel", "foreignKey": "userId"}
]
}
}'Generate Service Template
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-user-service" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": ["findAll", "findById", "create", "update", "delete", "search"],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": true,
"authentication": "JWT",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'API Template
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-users-api" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "UsersController",
"route": "/api/users",
"methods": ["GET", "POST", "PUT", "DELETE"],
"security": {
"auth": ["jwt"],
"roles": ["admin", "user"],
"rateLimit": {
"window": "1m",
"max": 100
},
"csrfProtection": true,
"inputSanitization": true,
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET", "POST", "PUT", "DELETE"]
}
},
"logging": {
"enabled": true,
"level": "info"
},
"errorHandling": true,
"databaseIntegration": "MongoDB",
"schemaValidation": true,
"responseFormat": "JSON",
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"versioning": "1.2.0"
}
}'Test with Complex Parameters
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-order-service" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "OrderService",
"methods": [
"findAll",
"findById",
"create",
"update",
"delete",
"processPayment",
"calculateTotal",
"validateOrder"
],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"logErrors": true,
"errorFormat": "detailed"
},
"authentication": {
"type": "JWT",
"roles": ["admin", "user"]
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 2000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"databaseIntegration": {
"type": "MongoDB",
"collections": ["orders"]
},
"schemaValidation": true,
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest"
],
"responseFormat": "JSON",
"versioning": "1.1.0"
}
}'Generate API
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-users-controller" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "UsersController",
"route": "/api/users",
"methods": ["GET", "POST", "PUT", "DELETE"],
"security": {
"auth": ["jwt"],
"roles": ["admin", "user"],
"rateLimit": {
"window": "1m",
"max": 100
},
"csrfProtection": true,
"inputSanitization": true,
"cors": {
"enabled": true,
"allowedOrigins": ["*"],
"allowedMethods": ["GET", "POST", "PUT", "DELETE"]
}
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"errorHandling": {
"enabled": true,
"logErrors": true,
"errorFormat": "detailed"
},
"databaseIntegration": {
"type": "MongoDB",
"collections": ["users"]
},
"schemaValidation": true,
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"handleErrors"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Microservice Infrastructure
Generate MI Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-microservice" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "MicroserviceInfrastructure",
"methods": [
"initializeServiceRegistry",
"configureServiceDiscovery",
"setupCircuitBreaker",
"implementRetryMechanism",
"setupDistributedTracing"
],
"serviceRegistry": {
"enabled": true,
"provider": "Consul",
"ttl": 30
},
"serviceDiscovery": {
"enabled": true,
"strategy": "round-robin"
},
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5,
"resetTimeout": 60000
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"observability": {
"healthChecks": {
"enabled": true,
"dependencies": ["database", "cache", "queue"]
},
"performanceMonitoring": true
},
"middleware": [
"validateRequest",
"logRequest",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'Load Testing
for i in {1..100}; do
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: load-test-$i" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"type": "service",
"parameters": {
"name": "LoadTestService",
"methods": ["simulateTraffic"],
"logging": true,
"errorHandling": true,
"rateLimiting": {
"enabled": true,
9 months ago