Package Exports
- @bleujs/core
- @bleujs/core/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bleujs/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
.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 bleujs
bleujs start
or
pnpm install bleujs@latest
pnpm run start
Retrieve Package Information
pnpm info bleujs
pnpm list | grep bleujs
Directory 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 32
Replace 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-engine
pnpm start
In 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,
"requestsPerMinute": 5000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 120
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"logRequest"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}' &
done
wait
Error Handling
Missing Required Fields
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-fixed-fields" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "FixedService",
"methods": ["testMethod"]
}
}'
Invalid Service Type
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-invalid-type" \
-H "Accept: application/json" \
-d '{
"type": "invalidType",
"parameters": {
"name": "InvalidTestService",
"methods": ["testMethod"]
}
}'
Generate 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" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "AuthenticationService",
"methods": [
"login",
"logout",
"refreshToken",
"validateSession",
"changePassword",
"resetPassword",
"generateTwoFactorCode",
"verifyTwoFactorCode",
"revokeToken",
"updateProfile"
],
"logging": {
"enabled": true,
"level": "info",
"format": "json"
},
"debug": true,
"dryRun": false,
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 1000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600
},
"security": {
"authentication": "JWT",
"authorizationRoles": ["admin", "user"],
"enforceTwoFactor": true
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
}
},
"retryPolicy": {
"enabled": true,
"maxRetries": 3,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest"
],
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'
Enterprise-grade
Health Check Test (/api/health)
curl -X GET "http://localhost:3001/api/health" \
-H "Content-Type: application/json" \
-H "X-Request-ID: health-check" \
-H "Accept: application/json" | jq '.'
Enterprise API cURL Test of Lambda
for i in {1..10}; do
curl -X POST "$HOST/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: lambda-api-test-$i" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d "{
\"type\": \"service\",
\"parameters\": {
\"name\": \"LambdaService$i\",
\"methods\": [\"method1\", \"method2\"],
\"tracing\": {
\"enabled\": true,
\"system\": \"AWS X-Ray\"
},
\"retryPolicy\": {
\"maxAttempts\": 3,
\"backoff\": \"exponential\"
},
\"logging\": {
\"enabled\": true,
\"level\": \"debug\"
}
}
}" > "lambda_response_$i.json" &
done
wait
Debugging Unexpected Outputs (Capturing Responses) (Logs and saves API responses for analysis)
for i in {1..10}; do
curl -s -o "debug_response_$i.json" -X POST "$HOST/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: debug-test-$i" \
-H "Accept: application/json" \
-d "{
\"type\": \"service\",
\"parameters\": {
\"name\": \"DebugService$i\",
\"methods\": [\"debugMethod1\", \"debugMethod2\"]
}
}" &
done
wait
CORS & OPTIONS Method Test (Ensures the API supports Cross-Origin Resource Sharing for frontend requests)
curl -v -X OPTIONS "$HOST/api/generate-egg" \
-H "Origin: http://localhost:3000" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: Content-Type"
Missing X-Request-ID Test (Verifies API error handling when required headers are missing)
curl -X POST "$HOST/api/generate-egg" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "MissingHeaderTest",
"methods": ["test"]
}
``` }' | jq '.'
Service Generation (Highly Scalable & Resilient)
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-enterprise-scale" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"type": "service",
"parameters": {
"name": "EnterpriseService",
"methods": [
"initializeSystem", "validateConfiguration", "processRequest",
"handleResponse", "manageCaching", "optimizePerformance",
"handleFailover", "processQueue", "validateSecurity", "manageResources"
],
"logging": {
"enabled": true,
"level": "debug",
"format": "json"
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
}
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 10000
},
"resilience": {
"circuitBreaker": {
"failureThreshold": 5,
"resetTimeout": 30000
},
"retryPolicy": {
"enabled": true,
"maxRetries": 5,
"backoffStrategy": "exponential"
}
},
"scalability": {
"loadBalancing": "round-robin",
"horizontalScaling": {
"enabled": true,
"minInstances": 3,
"maxInstances": 50
}
},
"parallelExecution": {
"enabled": true,
"workerThreads": 10
},
"security": {
"authentication": "oauth2",
"authorizationRoles": ["admin", "superuser", "operator"]
},
"responseFormat": "JSON",
"versioning": "2.1.0"
}
}' | jq '.'
Service Generation
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-enterprise-service" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "EnterpriseService",
"methods": [
"initializeSystem",
"validateConfiguration",
"processRequest",
"handleResponse",
"manageCaching",
"optimizePerformance",
"handleFailover",
"processQueue",
"validateSecurity",
"manageResources",
"monitorUptime",
"distributedLoadBalancing",
"autoScalingHandler",
"resourceOrchestration",
"disasterRecovery"
],
"scalability": {
"enabled": true,
"autoscaling": {
"minReplicas": 5,
"maxReplicas": 50,
"cpuThreshold": 70
},
"distributedExecution": true
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry",
"sampleRate": 0.1
},
"logging": {
"enabled": true,
"level": "info",
"format": "json"
}
},
"security": {
"authorizationRoles": ["admin", "devops", "auditor"],
"firewallRules": {
"enabled": true,
"whitelist": ["10.0.0.0/16"],
"blacklist": ["192.168.1.0/24"]
},
"dataEncryption": {
"enabled": true,
"algorithm": "AES-256"
}
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 10_000
},
"caching": {
"enabled": true,
"type": "distributed",
"backend": "Redis",
"expiration": 1200
},
"loadBalancing": {
"enabled": true,
"strategy": "round-robin"
},
"failover": {
"enabled": true,
"strategy": "hot-standby",
"replicationFactor": 3
},
"retryPolicy": {
"enabled": true,
"maxRetries": 5,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"logRequest",
"monitorPerformance",
"validateSecurity",
"handleErrors"
],
"responseFormat": "JSON",
"versioning": "2.1.0"
}
}'
Authentication Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-enterprise-auth-service" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "EnterpriseAuthenticationService",
"methods": [
"login",
"logout",
"refreshToken",
"validateSession",
"changePassword",
"resetPassword",
"generateTwoFactorCode",
"verifyTwoFactorCode",
"revokeToken",
"updateProfile",
"auditLogAccess",
"federatedLogin",
"sessionTermination",
"biometricAuth",
"adminOverride"
],
"scalability": {
"enabled": true,
"autoscaling": {
"minReplicas": 3,
"maxReplicas": 20,
"cpuThreshold": 75
}
},
"observability": {
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry",
"sampleRate": 0.1
},
"logging": {
"enabled": true,
"level": "debug",
"format": "json"
}
},
"security": {
"authentication": ["JWT", "OAuth2", "LDAP"],
"authorizationRoles": ["admin", "user", "auditor"],
"multiFactorAuth": true,
"biometricSupport": true
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 5000
},
"caching": {
"enabled": true,
"type": "redis",
"expiration": 900
},
"auditLogging": {
"enabled": true,
"storage": "S3",
"retentionPeriod": "90d"
},
"highAvailability": {
"enabled": true,
"failoverStrategy": "multi-region",
"replicationFactor": 3
},
"compliance": {
"standards": ["GDPR", "SOC2", "HIPAA"],
"encryption": {
"enabled": true,
"algorithms": ["AES-256", "RSA-4096"]
}
},
"retryPolicy": {
"enabled": true,
"maxRetries": 5,
"backoffStrategy": "exponential"
},
"middleware": [
"validateRequest",
"rateLimit",
"authenticateUser",
"logRequest",
"auditLogging",
"monitorPerformance"
],
"responseFormat": "JSON",
"versioning": "2.0.0"
}
}'
Edge Cases
for i in {1..5}; do
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: concurrent-test-$i" \
-d "{
\"type\": \"service\",
\"parameters\": {
\"name\": \"Service$i\",
\"methods\": [\"method$i\"]
}
}" >> concurrent_test_results.log 2>&1 &
done
wait
ProductController with full CRUD operations
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-product-controller" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"type": "controller",
"parameters": {
"name": "ProductController",
"route": "/api/products",
"methods": [
"listProducts",
"getProductDetails",
"createProduct",
"updateProduct",
"deleteProduct",
"searchProducts",
"exportToCsv",
"importFromCsv"
],
"security": {
"auth": ["jwt"],
"roles": ["admin", "seller"]
},
"validation": {
"schema": {
"productName": "string",
"price": "number",
"stock": "integer",
"category": "string"
}
},
"logging": {
"enabled": true,
"level": "info"
},
"errorHandling": true,
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 100
},
"csrfProtection": true,
"caching": {
"enabled": true,
"type": "redis",
"expiration": 300
},
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}'
Generate endpoint
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-factory" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"type": "factory",
"parameters": {
"name": "PaymentFactory",
"methods": [
"createPaymentProcessor",
"createPaymentGateway",
"createPaymentValidator",
"validatePaymentMethod",
"processTransaction"
],
"security": {
"auth": ["jwt"],
"roles": ["admin", "finance"]
},
"logging": {
"enabled": true,
"level": "info"
},
"errorHandling": true,
"caching": {
"enabled": true,
"type": "redis",
"expiration": 600
},
"metrics": {
"enabled": true,
"system": "Prometheus"
},
"tracing": {
"enabled": true,
"system": "OpenTelemetry"
},
"rateLimiting": {
"enabled": true,
"requestsPerMinute": 500
},
"responseFormat": "JSON",
"versioning": "1.2.0"
}
}' | jq '.'
Large Number of Methods With Categorization
`curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: advanced-large-methods" \
-d '{
"type": "service",
"parameters": {
"name": "EnterpriseScaleService",
"methods": [
"initializeSystem1", "initializeSystem2", "initializeSystem3", "initializeSystem4", "initializeSystem5",
"validateData1", "validateData2", "validateData3", "validateData4", "validateData5",
"processRequest1", "processRequest2", "processRequest3", "processRequest4", "processRequest5",
"handleResponse1", "handleResponse2", "handleResponse3", "handleResponse4", "handleResponse5",
"manageCaching1", "manageCaching2", "manageCaching3", "manageCaching4", "manageCaching5",
"optimizePerformance1", "optimizePerformance2", "optimizePerformance3", "optimizePerformance4", "optimizePerformance5",
"handleFailover1", "handleFailover2", "handleFailover3", "handleFailover4", "handleFailover5",
"processQueue1", "processQueue2", "processQueue3", "processQueue4", "processQueue5",
"validateSecurity1", "validateSecurity2", "validateSecurity3", "validateSecurity4", "validateSecurity5",
"manageResources1", "manageResources2", "manageResources3", "manageResources4", "manageResources5",
"handleErrors1", "handleErrors2", "handleErrors3", "handleErrors4", "handleErrors5",
"processEvents1", "processEvents2", "processEvents3", "processEvents4", "processEvents5",
"manageState1", "manageState2", "manageState3", "manageState4", "manageState5",
"optimizeMemory1", "optimizeMemory2", "optimizeMemory3", "optimizeMemory4", "optimizeMemory5",
"handleConcurrency1", "handleConcurrency2", "handleConcurrency3", "handleConcurrency4", "handleConcurrency5",
"processStream1", "processStream2", "processStream3", "processStream4", "processStream5",
"validateIntegrity1", "validateIntegrity2", "validateIntegrity3", "validateIntegrity4", "validateIntegrity5",
"manageConnections1", "manageConnections2", "manageConnections3", "manageConnections4", "manageConnections5",
"handleTimeout1", "handleTimeout2", "handleTimeout3", "handleTimeout4", "handleTimeout5",
"processCallback1", "processCallback2", "processCallback3", "processCallback4", "processCallback5",
"validatePermissions1", "validatePermissions2", "validatePermissions3", "validatePermissions4", "validatePermissions5"
]
}
}' | jq '.'`;
Changelog (v1.1.0)
- Fixed Babel build issues by adding missing plugins (@babel/plugin-proposal-optional-chaining, @babel/plugin-proposal-nullish-coalescing-operator).
- Updated dependencies to address compatibility issues.
- PM2 restart is required after pulling the latest changes.
Developer Setup
pnpm install
pnpm build
pm2 restart all
AI Tools
With built-in AI services like Natural Language Processing (NLP) and decision trees, developers can quickly integrate advanced AI capabilities into their applications without starting from scratch.
Backend Efficiency
The package includes setup using Express.js, MongoDB, and essential middleware like helmet for security, compression for performance, and cors for handling cross-origin requests. This allows developers to set up a scalable and secure backend efficiently.
Testing and Quality Assurance
bleujs integrates testing frameworks, including Jest for unit and integration tests, and Cypress for end-to-end tests. This ensures that applications built with this package are reliable and maintain high quality standards.
Code Linting and Formatting
By including ESLint and Prettier configurations, bleujs helps developers maintain consistent coding standards and formatting, reducing errors and improving code readability.
TypeScript Support
The package supports TypeScript, allowing developers to write safer and more maintainable code with type checking.
Swagger Documentation
The package includes tools for generating Swagger API documentation, making it easier for developers to document and share their API specifications.
Continuous Integration/Continuous Deployment (CI/CD)
The package comes with a CI/CD pipeline configuration for automated testing, linting, building, and deployment. This helps teams to integrate changes continuously and deploy applications reliably.
Docker Support
With Docker integration, developers can containerize their applications for consistent deployment across different environments. This ensures that the application runs seamlessly regardless of where it is deployed.
Real-time Features
To add real-time features like live notifications and updates to their applications.
Usage
Create an instance of the BleuJS class and use its methods to manage your code:
import BleuJS from 'bleu.js';
const bleu = new BleuJS();
const newEgg = bleu.generateEgg('This is a description of the new egg.');
console.log(newEgg);
const code = 'const x = 1; console.log(x);';
const optimizedCode = bleu.optimizeCode(code);
const dependencies = ['express', 'body-parser'];
bleu.manageDependencies(dependencies);
const isQualityCode = bleu.ensureCodeQuality(code);
console.log(`Is the code quality acceptable? ${isQualityCode}`);
bleujs-utils Package (Version 1.0.1)
The bleujs-util
package provides essential utility functions that are part of the Bleu.js framework. It simplifies the process of handling various coding challenges such as dependency management, code quality checks, and optimization.
Features
- Lightweight utility functions for common tasks.
- Dependency management utilities.
- Code optimization tools.
Installation
You can install the bleujs-utils package via pip
Using pip:
pip install bleujs-utils
CLI Package Information
bleujs-utils
You can view the package on PyPI: bleujs-utils on PyPI
Example 1: General Utility Function
from bleujs_utils import some_utility_function
result = some_utility_function(input_data)
print(result)
Example 2: Helper Functions for AI Integration
from bleujs_utils import ai_query
response = ai_query('What is the weather today?')
print(response)
- AI Query Tools: Provides helper functions for querying AI models, managing requests, and handling responses.
- Company Search: Utilities for fuzzy searching company names, perfect for customer service applications like HelloBlue.
- Error Handling: Custom logging and debugging utilities designed to streamline development and troubleshooting.
Example 3: CLI Tool
bleujs-utils-cli --help
Here’s how you can use the bleujs-utils
package in your project:
const { optimizeCode, manageDependencies } = require('bleujs-utils');
const code = 'const x = 1; console.log( x);';
const optimizedCode = optimizeCode(code);
console.log('Optimized Code:', optimizedCode);
const dependencies = ['express', 'body-parser'];
manageDependencies(dependencies);
Optimizing Code
The optimizeCode
function cleans up and formats code for better readability and performance.
const { optimizeCode } = require('bleujs-utils');
const code = 'const x = 1; console.log( x);';
const optimizedCode = optimizeCode(code);
console.log(optimizedCode);
Managing Dependencies
The manageDependencies
function helps you keep track of and manage your project dependencies efficiently.
const { manageDependencies } = require('bleujs-utils');
const dependencies = ['express', 'mongoose'];
manageDependencies(dependencies);
Class Documentation
'BleuJS'
The BleuJS class provides several methods to help you manage and optimize your code.
class Bleu {
constructor() {
this.eggs = [];
}
/**
* Generates a new code egg.
* @param {string} description - Description of the egg.
* @param {string} type - Type of the egg (e.g., 'model', 'utility').
* @param {object} options - Options for generating the egg.
* @returns {object} The generated egg.
*/
generateEgg(description, type, options) {
const code = this.generateCode(type, options);
const newEgg = {
id: this.eggs.length + 1,
description: this.generateDescription(type, options),
type,
code,
};
this.eggs.push(newEgg);
return newEgg;
}
/**
* Generates code based on type.
* @param {string} type - Type of the code (e.g., 'model', 'utility').
* @param {object} options - Options for generating the code.
* @returns {string} The generated code.
*/
generateCode(type, options) {
switch (type) {
case 'model':
return this.generateModel(options.modelName, options.fields);
case 'utility':
return this.generateUtility(options.utilityName, options.methods);
default:
throw new Error(`Unknown code type: ${type}`);
}
}
/**
* Generates model code.
* @param {string} modelName - Name of the model.
* @param {Array} fields - Fields of the model.
* @returns {string} The generated model code.
*/
generateModel(modelName, fields) {
let code = `class ${modelName} {\n`;
fields.forEach((field) => {
code += ` ${field.name}: ${field.type};\n`;
});
code += '}';
return code;
}
/**
* Generates utility code.
* @param {string} utilityName - Name of the utility.
* @param {Array} methods - Methods of the utility.
* @returns {string} The generated utility code.
*/
generateUtility(utilityName, methods) {
let code = `class ${utilityName} {\n`;
methods.forEach((method) => {
code += ` ${method}() {\n`;
code += ` // TODO: Implement ${method}\n`;
code += ' }\n';
});
code += '}';
return code;
}
/**
* Generates description based on type.
* @param {string} type - Type of the egg.
* @param {object} options - Options for generating the description.
* @returns {string} The generated description.
*/
generateDescription(type, options) {
switch (type) {
case 'model':
return `Model ${options.modelName} with fields ${options.fields.map((f) => f.name).join(', ')}`;
case 'utility':
return `Utility ${options.utilityName} with methods ${options.methods.join(', ')}`;
default:
throw new Error(`Unknown code type: ${type}`);
}
}
/**
* Optimizes the provided code.
* @param {string} code - The code to optimize.
* @returns {string} The optimized code.
*/
optimizeCode(code) {
return code.replace(/\s+/g, ' ').trim();
}
/**
* Manages dependencies.
* @param {Array} dependencies - List of dependencies.
*/
manageDependencies(dependencies) {
dependencies.forEach((dep) => {
console.log(`Managing dependency: ${dep}`);
});
}
/**
* Ensures code quality.
* @param {string} code - The code to check.
* @returns {boolean} Whether the code is of high quality.
*/
ensureCodeQuality(code) {
return !code.includes('var');
}
}
module.exports = Bleu;
Bleu
✓ should generate a new egg (1 ms)
✓ should optimize code
✓ should manage dependencies (10 ms)
✓ should ensure code quality
✓ should generate multiple eggs
✓ should handle large number of eggs (3 ms)
✓ should handle complex optimization
✓ should ensure quality of complex code
Test Suites: 1 passed, 1 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 0.359 s, estimated 1 s
Ran all test suites.
Constructor
constructor();
Structure
class Bleu {
constructor() {
this.eggs = [];
}
generateEgg(description, type, options = {}) {
const newEgg = {
id: this.eggs.length + 1,
description,
type,
code: this.generateCode(type, options),
};
this.eggs.push(newEgg);
return newEgg;
}
generateCode(type, options) {
switch (type) {
case 'model':
return this.generateModel(options.modelName, options.fields);
case 'controller':
return this.generateController(options.controllerName, options.actions);
case 'utility':
return this.generateUtility(options.utilityName, options.methods);
default:
throw new Error(`Unknown code type: ${type}`);
}
}
generateModel(modelName, fields) {
const classFields = fields
.map((field) => ` ${field.name}: ${field.type};`)
.join('\n');
const classMethods = fields
.map(
(field) =>
` get${field.name.charAt(0).toUpperCase() + field.name.slice(1)}() { return this.${field.name}; }`,
)
.join('\n\n');
return `
class ${modelName} {
${classFields}
constructor(${fields.map((field) => field.name).join(', ')}) {
${fields.map((field) => `this.${field.name} = ${field.name};`).join('\n ')}
}
${classMethods}
}
module.exports = ${modelName};
`;
}
generateController(controllerName, actions) {
const actionMethods = actions
.map(
(action) => `
${action}() {
// ${action} logic here
}`,
)
.join('\n');
return `
class ${controllerName} {
${actionMethods}
}
module.exports = ${controllerName};
`;
}
generateUtility(utilityName, methods) {
const utilityMethods = methods
.map(
(method) => `
${method.name}(${method.params.join(', ')}) {
${method.body}
}`,
)
.join('\n');
return `
class ${utilityName} {
${utilityMethods}
}
module.exports = ${utilityName};
`;
}
optimizeCode(code) {
const optimizedCode = code;
return optimizedCode;
}
manageDependencies(dependencies) {
dependencies.forEach((dep) => {
console.log(`Managing dependency: ${dep}`);
});
}
ensureCodeQuality(code) {
const isQualityCode = true;
return isQualityCode;
}
}
module.exports = Bleu;
const Bleu = require('./Bleu');
const bleu = new Bleu();
const newEgg = bleu.generateEgg('This is a test egg', 'model', {
modelName: 'TestModel',
fields: [
{ name: 'field1', type: 'string' },
{ name: 'field2', type: 'number' },
],
});
const code = 'const x = 1; console.log(x);';
const optimizedCode = bleu.optimizeCode(code);
console.log('Optimized Code:', optimizedCode);
const isQualityCode = bleu.ensureCodeQuality(code);
console.log('Is the code quality acceptable?', isQualityCode);
const dependencies = ['express', 'body-parser'];
bleu.manageDependencies(dependencies);
pnpm test
PASS tests/bleu.test.js
API Tests
✓ should return Hello, World! on GET / (49 ms)
✓ should create data on POST /data (113 ms)
✓ should create multiple data entries on POST /data (114 ms)
✓ should handle /data with body {} (10 ms)
✓ should handle /nonexistent with body null (6 ms)
✓ should handle /data with body Invalid JSON (5 ms)
✓ should handle asynchronous errors gracefully (12 ms)
✓ should handle edge cases (4 ms)
✓ should ensure performance meets expectations (4 ms)
✓ should return 400 for missing data field in POST /data (5 ms)
✓ should return 500 for simulated server error in POST /data (7 ms)
✓ should handle invalid JSON gracefully (3 ms)
✓ should handle very large data payloads (106 ms)
✓ should measure response time for POST /data (110 ms)
✓ should handle simultaneous requests (148 ms)
✓ should validate response schema (6 ms)
✓ should stress test the server (263 ms)
✓ should test with invalid routes (5 ms)
✓ should test JSON parsing error (3 ms)
✓ should test different HTTP methods on /data (5 ms)
✓ should handle very large number of simultaneous requests (1235 ms)
✓ should handle concurrent GET and POST requests (108 ms)
✓ should handle slow network conditions gracefully (110 ms)
✓ should handle invalid request headers (10 ms)
✓ should verify CORS headers (7 ms)
✓ should handle session cookies (116 ms)
✓ should verify content-type for POST /data (9 ms)
✓ should test for memory leaks (274 ms)
✓ should handle different user roles (111 ms)
✓ should handle database connectivity issues (5 ms)
✓ should handle multipart/form-data (110 ms)
✓ should handle application/x-www-form-urlencoded (113 ms)
✓ should handle JSON arrays (11 ms)
✓ should handle deeply nested JSON objects (114 ms)
Test Suites: 1 passed, 1 total
Tests: 34 passed, 34 total
Snapshots: 0 total
Time: 3.707 s, estimated 4 s
Ran all test suites.
Initializes a new instance of the BleuJS class
Methods
Class Constructor:
The class constructor initializes the Bleu object with an empty array eggs to store the generated code 'eggs'. This array acts as a container for all the code snippets, models, utilities, and other structures created using the generateEgg method.
- Initializes an empty array eggs to store the generated code 'eggs'.
constructor() {
this.eggs = [];
this.henFarm = new HenFarm();
}
generateEgg Method:
The generateEgg method is responsible for generating a new code 'egg'. This method leverages the HenFarm.js framework to produce code snippets based on the specified type and options. Each generated egg is assigned a unique ID, a description, and the generated code. The egg is then added to the eggs array and returned.
- Utilize HenFarm.js to generate code based on the provided type and options.
- Create a new egg object with a unique ID, description, type, generated code, and creation timestamp.
- Append the new egg to the eggs array.
- Return the newly created egg.
Eggs Generator API
The Eggs Generator API is a microservice that generates custom AI-powered "eggs" based on provided parameters. This API is designed for scalability, AI logic, and real-time egg generation.
If you want faster execution and better debugging, use:
curl -X POST http://localhost:3003/api/eggs/generate-egg \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "User-Agent: Curl-Advanced-Test" \
-H "Cache-Control: no-cache" \
-d '{
"type": "celestial",
"description": "A rare legendary egg",
"parameters": {
"size": "large",
"color": "gold",
"rarity": "legendary",
"element": "magic"
}
}' \
--fail --silent --show-error --output response.json
Then, check your response.json
Expected result
{"success":true,"result":{"id":"990321c6-7cae-472f-933d-743a9ac8022c","type":"dragon","description":"A rare legendary egg","metadata":{"tags":[],"version":"1.0.37","generatedBy":"Eggs-Generator v1.0.37","properties":{"rarity":"legendary","element":"fire"},"rarity":"legendary","attributes":[{"trait_type":"element","value":"fire","rarity_score":4,"_id":"67b0a38eae7bb50b80649417"}],"dna":"1bd6e02ead46f6927bf1c5f185bfcf38","generation":1,"aiFingerprint":"9833bf1a6f857eac2fe43e0d42d8cf6b6c45382300ff0146dc396441457c536c"},"status":"incubating","incubationConfig":{"startTime":"2025-02-15T14:24:14.877Z","duration":86400,"temperature":37,"conditions":[],"optimalTemp":37},"evolution":{"stage":1,"powerLevel":104,"experience":0,"history":[],"possibleEvolutions":[]},"interactions":{"total":0,"history":[]},"owner":"system","tradeable":true,"market":{"listed":false,"bids":[],"realTimePrice":0,"priceHistory":[]},"security":{"validation":false,"signature":"233b4233de9948536c2931dfd876e2c66ad4ffe2bb46e8e9e7fca464994d1a5a"},"_id":"67b0a38eae7bb50b80649416","ownershipHistory":[],"createdAt":"2025-02-15T14:24:14.881Z","updatedAt":"2025-02-15T14:24:14.881Z","__v":0},"market":{"tier":{"eggsPerDay":5,"rarities":["common","uncommon"],"price":0},"tradingEnabled":false}}%
curl -X POST http://localhost:3003/api/eggs/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "celestial",
"description": "A rare legendary egg",
"parameters": { "size": "large", "color": "gold", "rarity": "legendary", "element": "magic" }
}'
Expected result
Generated Egg: {
id: '9854f6da-b409-4b72-bd30-7e545d79b1a7',
type: 'golden-egg',
description: 'A rare legendary egg',
metadata: {
size: 'large',
color: 'gold',
generatedBy: 'Eggs-Generator v1.0.37',
timestamp: '2025-02-09T06:14:51.061Z'
},
createdAt: '2025-02-09T06:14:51.061Z',
updatedAt: '2025-02-09T06:14:51.061Z'
}
2025-02-09T06:14:51.063Z [INFO]: ✅ Egg Generated Successfully {"result":{"id":"9854f6da-b409-4b72-bd30-7e545d79b1a7","type":"golden-egg","description":"A rare legendary egg","metadata":{"size":"large","color":"gold","generatedBy":"Eggs-Generator v1.0.37","timestamp":"2025-02-09T06:14:51.061Z"},"createdAt":"2025-02-09T06:14:51.061Z","updatedAt":"2025-02-09T06:14:51.061Z"}}
{
"type": "golden-egg",
"description": "A rare legendary egg",
"parameters": {
"size": "large",
"color": "gold"
}
}
Response (Example)
{
"result": {
"id": "75525d38-b458-4493-80c2-a0b01ff64c66",
"type": "golden-egg",
"description": "A rare legendary egg",
"metadata": {
"size": "large",
"color": "gold",
"generatedBy": "Eggs-Generator v1.0.38",
"timestamp": "2025-02-09T01:12:03.933Z"
},
"createdAt": "2025-02-09T01:12:03.933Z",
"updatedAt": "2025-02-09T01:12:03.933Z"
}
}
PASS tests/bleu.test.js
API Tests
✓ should return Hello, World! on GET / (49 ms)
✓ should create data on POST /data (113 ms)
✓ should create multiple data entries on POST /data (114 ms)
✓ should handle /data with body {} (10 ms)
✓ should handle /nonexistent with body null (6 ms)
✓ should handle /data with body Invalid JSON (5 ms)
✓ should handle asynchronous errors gracefully (12 ms)
✓ should handle edge cases (4 ms)
✓ should ensure performance meets expectations (4 ms)
✓ should return 400 for missing data field in POST /data (5 ms)
✓ should return 500 for simulated server error in POST /data (7 ms)
✓ should handle invalid JSON gracefully (3 ms)
✓ should handle very large data payloads (106 ms)
✓ should measure response time for POST /data (110 ms)
✓ should handle simultaneous requests (148 ms)
✓ should validate response schema (6 ms)
✓ should stress test the server (263 ms)
✓ should test with invalid routes (5 ms)
✓ should test JSON parsing error (3 ms)
✓ should test different HTTP methods on /data (5 ms)
✓ should handle very large number of simultaneous requests (1235 ms)
✓ should handle concurrent GET and POST requests (108 ms)
✓ should handle slow network conditions gracefully (110 ms)
✓ should handle invalid request headers (10 ms)
✓ should verify CORS headers (7 ms)
✓ should handle session cookies (116 ms)
✓ should verify content-type for POST /data (9 ms)
✓ should test for memory leaks (274 ms)
✓ should handle different user roles (111 ms)
✓ should handle database connectivity issues (5 ms)
✓ should handle multipart/form-data (110 ms)
✓ should handle application/x-www-form-urlencoded (113 ms)
✓ should handle JSON arrays (11 ms)
✓ should handle deeply nested JSON objects (114 ms)
Test Suites: 1 passed, 1 total
Tests: 34 passed, 34 total
Snapshots: 0 total
Time: 3.707 s, estimated 4 s
Ran all test suites.
pnpm test
> bleujs@1.1.0 test /Users/Bleu.js
> jest --detectOpenHandles --forceExit
PASS lint coverage/prettify.js
✓ ESLint (66 ms)
PASS lint coverage/lcov-report/prettify.js
✓ ESLint (29 ms)
PASS lint dependency-management/coverage/prettify.js
✓ ESLint (30 ms)
PASS lint dependency-management/coverage/lcov-report/prettify.js
✓ ESLint (105 ms)
PASS lint venv/lib/python3.13/site-packages/werkzeug/debug/shared/debugger.js
✓ ESLint (12 ms)
PASS lint eggs-generator/src/types/egg.types.js
✓ ESLint (6 ms)
PASS lint backend/src/src/controllers/apiController.js
✓ ESLint (6 ms)
PASS lint eggs-generator/src/routes/egg.routes.js
✓ ESLint (11 ms)
PASS lint coverage/lcov-report/sorter.js
✓ ESLint (8 ms)
PASS lint coverage/sorter.js
✓ ESLint (4 ms)
PASS lint dependency-management/coverage/sorter.js
✓ ESLint (4 ms)
PASS lint dependency-management/coverage/lcov-report/sorter.js
✓ ESLint (3 ms)
PASS lint backend/src/src/ai/decisionTree.js
✓ ESLint (6 ms)
PASS lint frontend/src/index.js
✓ ESLint (3 ms)
PASS lint frontend/public/app.js
✓ ESLint (4 ms)
PASS lint ./jest.setup.js
✓ ESLint (7 ms)
PASS lint eggs-generator/src/services/egg.service.js
✓ ESLint (4 ms)
PASS lint eggs-generator/src/events/eggEvents.js
✓ ESLint (6 ms)
PASS lint src/backend/src/controllers/apiController.js
✓ ESLint (5 ms)
PASS lint eggs-generator/src/Bleu.js
✓ ESLint (2 ms)
PASS lint backend/src/src/controllers/rulesController.js
✓ ESLint (3 ms)
PASS lint backend/src/tests/CustomSequencer.js
✓ ESLint (2 ms)
PASS lint src/backend/routes.js
✓ ESLint (6 ms)
PASS lint src/backend/src/ai/decisionTree.js
✓ ESLint (3 ms)
PASS lint eggs-generator/src/models/egg.model.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/apiGenerateEgg.test.js
✓ ESLint (1 ms)
PASS lint backend/src/src/models/ruleModel.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/CustomSequencer.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/apiController.test.js
✓ ESLint (1 ms)
PASS lint backend/src/src/services/aiService.js
✓ ESLint (3 ms)
PASS lint src/backend/tests/decisionTree.test.js
✓ ESLint (1 ms)
PASS lint backend/src/src/controllers/dataController.js
✓ ESLint (1 ms)
PASS lint ./manualConnectionTest.js
✓ ESLint (2 ms)
PASS lint src/backend/src/services/aiService.js
✓ ESLint (1 ms)
PASS lint coverage/lcov-report/block-navigation.js
✓ ESLint (1 ms)
PASS lint coverage/block-navigation.js
✓ ESLint (3 ms)
PASS lint dependency-management/coverage/lcov-report/block-navigation.js
✓ ESLint (2 ms)
PASS lint dependency-management/coverage/block-navigation.js
✓ ESLint (4 ms)
PASS lint src/backend/tests/testUtils.js
✓ ESLint (2 ms)
PASS lint backend/src/src/ai/nlpProcessor.js
✓ ESLint (1 ms)
PASS lint eggs-generator/__tests__/index.test.js
✓ ESLint (1 ms)
PASS lint backend/src/src/routes/apiRoutes.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/testSequencer.test.js
✓ ESLint (2 ms)
PASS lint src/backend/src/ai/nlpProcessor.js
✓ ESLint (2 ms)
PASS lint dependency-management/src/index.js
✓ ESLint (1 ms)
PASS lint backend/src/src/ml/modelManager.js
✓ ESLint (2 ms)
PASS lint backend/src/src/services/rulesEngine.js
✓ ESLint (3 ms)
PASS lint dependency-management/test.js
✓ ESLint (1 ms)
PASS lint backend/src/src/services/ruleService.js
✓ ESLint (1 ms)
PASS lint src/backend/src/ml/modelManager.js
✓ ESLint (1 ms)
PASS lint src/models/egg.schema.js
✓ ESLint (1 ms)
PASS lint src/backend/src/controllers/dataController.js
✓ ESLint (2 ms)
PASS lint src/controllers/eggController.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/seedDatabase.test.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/aiService.test.js
✓ ESLint (1 ms)
PASS lint backend/src/mocks/AiQuery.js
✓ ESLint (2 ms)
PASS lint src/backend/src/services/rulesEngine.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/apiRoutes.test.js
✓ ESLint (3 ms)
PASS lint backend/src/html-report/jest-html-reporters-attach/report/index.js
✓ ESLint (1 ms)
PASS lint backend/src/src/utils/testSequencer.js
✓ ESLint (2 ms)
PASS lint language-plugins/javascript/src/index.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/generateEgg.js
✓ ESLint (1 ms)
PASS lint src/backend/html-report/jest-html-reporters-attach/report/index.js
✓ ESLint
PASS lint backend/src/src/routes/dataRoutes.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/db/mongodb.js
✓ ESLint (1 ms)
PASS lint backend/src/src/services/decisionTreeService.js
✓ ESLint (1 ms)
PASS lint backend/src/src/models/userModel.js
✓ ESLint (1 ms)
PASS lint src/middleware/security.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/utils/metrics.js
✓ ESLint (1 ms)
PASS lint backend/src/mocks/database.js
✓ ESLint (1 ms)
PASS lint backend/src/src/models/AiQuery.js
✓ ESLint
PASS lint src/middleware/auth.js
✓ ESLint
PASS lint language-plugins/javascript/tests/index.test.js
✓ ESLint (2 ms)
PASS lint src/backend/src/utils/testSequencer.js
✓ ESLint (1 ms)
PASS lint dependency-management/src/dependencyManager.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/aiTests.test.js
✓ ESLint (1 ms)
PASS lint src/backend/src/routes/dataRoutes.js
✓ ESLint (1 ms)
PASS lint backend/src/src/services/seedDatabase.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/HenFarm.js
✓ ESLint (1 ms)
PASS lint backend/src/src/utils/logger.js
✓ ESLint (1 ms)
PASS lint src/backend/mocks/AiQuery.js
✓ ESLint (1 ms)
PASS lint language-plugins/javascript/src/JSProcessor.js
✓ ESLint (1 ms)
PASS lint backend/src/tests/globalTeardown.js
✓ ESLint (1 ms)
PASS lint backend/src/tests/globalSetup.js
✓ ESLint (1 ms)
PASS lint src/routes/eggs.js
✓ ESLint (1 ms)
PASS lint backend/src/src/routes/index.js
✓ ESLint (1 ms)
PASS lint src/backend/src/models/userModel.js
✓ ESLint (1 ms)
PASS lint eggs-generator/__mocks__/HenFarm.js
✓ ESLint (1 ms)
PASS lint eggs-generator/deploy/deploy.js
✓ ESLint
PASS lint src/backend/tests/bleu.test.js
✓ ESLint
PASS lint eggs-generator/src/middleware/errorHandler.js
✓ ESLint
PASS lint src/backend/swagger.js
✓ ESLint (3 ms)
PASS lint src/backend/src/services/seedDatabase.js
✓ ESLint (1 ms)
PASS lint src/backend/src/models/AiQuery.js
✓ ESLint
PASS lint backend/src/src/routes/simpleRoute.js
✓ ESLint (2 ms)
PASS lint eggs-generator/test-db.js
✓ ESLint (1 ms)
PASS lint ./generateRuleId.js
✓ ESLint (2 ms)
PASS lint eggs-generator/src/middleware/validation.js
✓ ESLint (1 ms)
PASS lint eggs-generator/ecosystem.config.js
✓ ESLint (1 ms)
PASS lint ./vite.config.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/globalTeardown.js
✓ ESLint (1 ms)
PASS lint src/backend/src/utils/logger.js
✓ ESLint (1 ms)
PASS lint code-quality-assurance/tests/index.test.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/globalSetup.js
✓ ESLint (1 ms)
PASS lint backend/src/src/services/mockEngine.js
✓ ESLint (1 ms)
PASS lint scripts/preinstall.js
✓ ESLint (2 ms)
PASS lint ./preinstall.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/setup.js
✓ ESLint
PASS lint src/backend/src/utils/lib/Bleu.js
✓ ESLint
PASS lint backend/ecosystem.config.js
✓ ESLint (1 ms)
PASS lint backend/src/tests/setupTests.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/setupTests.js
✓ ESLint (1 ms)
PASS lint src/backend/src/services/mockEngine.js
✓ ESLint (1 ms)
PASS lint ./jestSequencer.js
✓ ESLint (1 ms)
PASS lint code-quality-assurance/src/index.js
✓ ESLint (1 ms)
PASS lint src/backend/src/routes/simpleRoute.js
✓ ESLint (1 ms)
PASS lint src/backend/src/routes/index.js
✓ ESLint (2 ms)
PASS lint ./eslint.config.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/utils/asyncHandler.js
✓ ESLint (1 ms)
PASS lint dependency-management/jest.setup.js
✓ ESLint (4 ms)
PASS lint src/backend/src/routes/metricsRoutes.js
✓ ESLint (2 ms)
PASS lint src/backend/src/routes/healthRoutes.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/validators/egg.validator.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/middleware/metrics.js
✓ ESLint (1 ms)
PASS lint eggs-generator/asyncHandler.js
✓ ESLint (1 ms)
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
dist | 0 | 0 | 0 | 0 |
routes.js | 0 | 0 | 0 | 0 | 5-914
swagger.js | 0 | 100 | 100 | 0 | 4-23
dist/utils | 0 | 0 | 0 | 0 |
logger.js | 0 | 100 | 0 | 0 | 5-10
testSequencer.js | 0 | 0 | 0 | 0 | 5-725
dist/utils/lib | 0 | 0 | 0 | 0 |
Bleu.js | 0 | 0 | 0 | 0 | 5-78
-------------------|---------|----------|---------|---------|-------------------
Test Suites: 2 skipped, 91 passed, 91 of 93 total
Tests: 91 passed, 91 total
Snapshots: 0 total
Time: 5.811 s
Ran all test suites.
📦 report is created on: /Users/pejmanhaghighatnia/Bleu.js/reports/test-report.html
** jest-stare --reporters: wrote output report to ./reports/jest-stare/index.html **
Main Test Report
open ./reports/test-report.html
Detailed Jest Report
open ./reports/jest-stare/index.html
optimizeCode Method:
The optimizeCode method is designed to optimize the provided code. While currently a placeholder, this method will implement advanced code optimization techniques to enhance performance and efficiency.
- Placeholder for code optimization logic.
- Returns the optimized code.
optimizeCode(code) {
const optimizedCode = code.replace(/\s+/g, ' ').trim();
return optimizedCode;
}
ensureCodeQuality Method:
The ensureCodeQuality method will ensure that the provided code meets predefined quality standards. This placeholder will incorporate code analysis tools and techniques to validate the code's quality.
- Placeholder for code quality assurance logic.
- Returns a boolean indicating whether the code meets quality standards.
ensureCodeQuality(code) {
const isQualityCode = true;
return isQualityCode;
}
This document provides detailed information about the API endpoints available in the Bleu.js application, including the recent updates and improvements made to the API.
(On Linux, use xdg-open index.html, or open it manually on Windows.)
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 95.0 | 92.5 | 93.0 | 94.0 | |
src/utils | 100.0 | 85.0 | 100.0 | 100.0 | |
backend/services | 90.0 | 95.0 | 88.0 | 91.0 | 45, 67 |
------------------- | --------- | ---------- | --------- | --------- | ------------------- |
Test Report Overview
Here’s a snapshot of the latest test suite execution for the Bleu.js framework. Our commitment to quality ensures a robust and reliable experience for developers.
Summary
Metric | Value |
---|---|
Test Suites Total | 98 |
Tests Total | 97 |
Failed Suites | 0 |
Failed Tests | 0 |
Pending Suites | 1 |
Pending Tests | 0 |
Test Coverage | 100% |
Execution Details
Key Metrics | Value |
---|---|
Start Time | 2025-01-23 11:45:41 |
Total Execution Time | 00:05.928 seconds |
Max Workers Utilized | 7 |
Framework Version | 1.0.29 |
Detailed Execution
Bleu.js ensures all test cases pass successfully, delivering a seamless experience for developers. Below are key highlights from the executed suite:
🏗️ Top-Level Files
File | Exec Time (s) | Status |
---|---|---|
/src/backend/tests/setup.ts |
00:00.015 | ✅ Passed |
/src/backend/tests/aiTests.test.js |
00:00.003 | ✅ Passed |
/output/jest-html-reporters-attach/... |
00:01.462 | ✅ Passed |
/coverage/prettify.js |
00:00.012 | ✅ Passed |
Backend Highlights
File | Exec Time (s) | Status |
---|---|---|
/src/backend/src/controllers/... |
00:00.007 | ✅ Passed |
/src/backend/src/utils/lib/Bleu.js |
00:00.002 | ✅ Passed |
/src/backend/tests/apiRoutes.test.js |
00:00.002 | ✅ Passed |
/src/backend/src/services/decision... |
00:00.001 | ✅ Passed |
Core Engine Highlights
File | Exec Time (s) | Status |
---|---|---|
/core-engine/src/BleuX.js |
00:00.001 | ✅ Passed |
/core-engine/src/index.js |
00:00.003 | ✅ Passed |
Swagger Documentation:
* @swagger
* /debug:
* post:
* summary: Debug logic
* tags: [Debug]
* responses:
* 200:
* description: Debugging
* content:
* application/json:
* schema:
* type: string
* example: Debugging
*/
router.post('/debug', (req, res) => {
res.send('Debugging');
});
POST /optimize
Handles optimization logic.
- URL: /optimize
- Method: POST
- Response:
`"Optimizing"`;
Swagger Documentation:
/**
* @swagger
* /optimize:
* post:
* summary: Optimize logic
* tags: [Optimization]
* responses:
* 200:
* description: Optimizing
* content:
* application/json:
* schema:
* type: string
* example: Optimizing
*/
router.post('/optimize', (req, res) => {
res.send('Optimizing');
});
POST /generate
Handles generation logic.
- URL: /generate
- Method: POST
- Response:
`"Generating"`;
Swagger Documentation:
/**
* @swagger
* /generate:
* post:
* summary: Generate logic
* tags: [Generation]
* responses:
* 200:
* description: Generating
* content:
* application/json:
* schema:
* type: string
* example: Generating
*/
router.post('/generate', (req, res) => {
res.send('Generating');
});
API Documentation
The API documentation is available at http://localhost:3003/docs
and provides detailed information about all available endpoints, request parameters, and response structures.
Here is an example of how Swagger documentation is added for an endpoint in the backend/server.js file:
/**
* @swagger
* /:
* get:
* summary: Returns a greeting message
* responses:
* 200:
* description: A JSON object containing a greeting message
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Hello, World!
*/
app.get('/', (req, res) => {
res.status(200).json({ message: 'Hello, World!' });
});
Security
The API supports bearer token authentication for secure endpoints. The security schema is defined as follows:
const swaggerDefinition = {
openapi: '3.0.0',
info: {
title: 'Bleu.js API',
version: '1.0.0',
description: 'Documentation for the Bleu.js API',
},
servers: [
{
url: 'http://localhost:3003',
},
],
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
},
},
},
security: [
{
bearerAuth: [],
},
],
};
License
Bleu.js is licensed under the MIT License
This software is maintained by Helloblue, Inc., a company dedicated to advanced innovations in AI solutions.
Author
Pejman Haghighatnia