bleujs
v1.0.36
Published
A production-ready AI framework for Decision Tree services, supporting Deep Learning, Neural Networks, and Model Deployment.
Downloads
651
Maintainers
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
Installation
Install the bleujs
package using pnpm:
pnpm install bleujs@latest
or
pnpm add bleujs
pnpm list | grep bleujs
Retrieve Package Information
pnpm info 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.
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.
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
Limbda, Bleujs REST API tests package
Starting the Server
cd core-engine
To test All APIs (In a new terminal)
./api_test_suite.sh
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" \
-d '{
"type": "model",
"parameters": {
"name": "OrderModel",
"methods": [
"validateBeforeSave",
"calculateTotals",
"applyDiscount",
"generateInvoice"
]
}
}'
Generate Service Class
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-service" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": [
"findAll",
"findOne",
"create",
"update",
"delete",
"validateBeforeSave"
]
}
}'
Generate Controller
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-controller" \
-d '{
"type": "controller",
"parameters": {
"name": "ProductController",
"methods": [
"listProducts",
"getProductDetails",
"createProduct",
"updateProduct",
"deleteProduct",
"searchProducts"
]
}
}'
Generate Repository
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-repository" \
-d '{
"type": "repository",
"parameters": {
"name": "OrderRepository",
"methods": [
"findById",
"findAll",
"findByCategory",
"createBulk",
"updateMany",
"softDelete"
]
}
}'
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" \
-d '{
"type": "service",
"parameters": {
"name": "EventSourcingEngine",
"methods": [
"appendToEventStream",
"reconstructAggregateState",
"handleEventReplay",
"manageEventStore",
"versionSnapshot"
]
}
}'
Controller generation
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "controller",
"parameters": {
"name": "UserController",
"actions": ["list", "create", "update", "delete", "authenticate"]
}
}'
Model generation
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "model",
"parameters": {
"name": "User",
"fields": ["username", "email", "password", "role"]
}
}'
Service generation
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": ["getAll", "getById", "create", "update", "delete"]
}
}'
API endpoint generation
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "api",
"parameters": {
"route": "/hello",
"message": "Hello World!"
}
}'
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": ["findAll", "findById", "create", "update", "delete"]
}
}'
Generate Microservice with Advanced Features
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "PaymentService",
"methods": [
"processPayment",
"validateCard",
"calculateFees",
"generateInvoice",
"refundTransaction",
"getTransactionHistory"
],
"options": {
"caching": true,
"validation": true,
"metrics": true,
"tracing": true,
"circuitBreaker": {
"failureThreshold": 5,
"resetTimeout": 60000
},
"retryPolicy": {
"maxAttempts": 3,
"backoff": "exponential"
}
}
}
}'
Generate REST API with Authentication
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "api",
"parameters": {
"route": "/api/payments",
"security": {
"auth": ["jwt", "apiKey"],
"roles": ["admin", "operator"],
"rateLimit": {
"window": "1m",
"max": 100
}
},
"methods": ["GET", "POST", "PUT", "DELETE"],
"validation": {
"schema": {
"amount": "number",
"currency": "string",
"description": "string?"
}
}
}
}'
Generate Event-Driven Service
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "NotificationService",
"events": [
"userRegistered",
"orderPlaced",
"paymentProcessed",
"orderShipped"
],
"integrations": [
"kafka",
"redis",
"elasticsearch"
],
"options": {
"retries": true,
"deadLetterQueue": true,
"monitoring": true
}
}
}'
Generate GraphQL API
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "graphql",
"parameters": {
"name": "UserAPI",
"types": [
{"name": "User", "fields": ["id", "name", "email"]},
{"name": "Order", "fields": ["id", "total", "items"]}
],
"queries": ["getUser", "listUsers", "searchUsers"],
"mutations": ["createUser", "updateUser", "deleteUser"]
}
}'
Deep Health Check
curl -X POST http://localhost:3001/api/health/deep \
-H "Content-Type: application/json" \
-d '{
"checkDependencies": true,
"timeout": 5000,
"services": ["database", "cache", "queue"]
}'
Generate Load Test
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "test",
"parameters": {
"name": "PaymentAPILoadTest",
"scenarios": [
"highConcurrency",
"errorScenarios",
"timeouts"
],
"metrics": [
"latency",
"throughput",
"errorRate"
],
"duration": "5m",
"users": 1000
}
}'
Generate Documentation
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "docs",
"parameters": {
"name": "PaymentAPI",
"format": "openapi",
"version": "3.0.0",
"sections": [
"overview",
"authentication",
"endpoints",
"schemas",
"examples"
]
}
}'
Generate Deployment Config
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "deployment",
"parameters": {
"name": "PaymentService",
"platform": "kubernetes",
"components": [
"deployment",
"service",
"ingress",
"configmap",
"secrets"
],
"resources": {
"cpu": "500m",
"memory": "512Mi",
"replicas": 3
}
}
}'
Get Metrics
curl http://localhost:3001/api/metrics
Generate Migration
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "migration",
"parameters": {
"name": "AddPaymentFields",
"database": "postgresql",
"changes": [
{"type": "addColumn", "table": "payments", "column": "status"},
{"type": "createIndex", "table": "payments", "columns": ["status"]}
]
}
}'
Generate Service Template
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "UserService",
"methods": ["findAll", "findById", "create", "update", "delete", "search"]
}
}'
API Template
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "api",
"parameters": {
"route": "/api/users",
"message": "User Management API",
"methods": ["GET", "POST", "PUT", "DELETE"]
}
}'
Test with Complex Parameters
curl -X POST http://localhost:3001/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"parameters": {
"name": "OrderService",
"methods": ["findAll", "findById", "create", "update", "delete", "processPayment", "calculateTotal", "validateOrder"],
"options": {
"caching": true,
"validation": true,
"metrics": true,
"tracing": true
}
}
}'
Generate API
curl -X POST http://localhost:3001/api/generate-egg \ -H "Content-Type: application/json" \ -d '{ "type": "api", "parameters": { "route": "/users", "message": "Users API" } }'
Generate Service
curl -X POST http://localhost:3001/api/generate-egg \ -H "Content-Type: application/json" \ -d '{ "type": "service", "parameters": { "name": "UserService", "methods": ["findAll", "findById", "create", "update", "delete"] } }'
Microservice Infrastructure
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-microservice" \
-d '{
"type": "service",
"parameters": {
"name": "MicroserviceInfrastructure",
"methods": [
"initializeServiceRegistry",
"configureServiceDiscovery",
"setupCircuitBreaker",
"implementRetryMechanism",
"setupDistributedTracing"
]
}
}'
Load Testing
for i in {1..5}; do
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: load-test-$i" \
-d "{
\"type\": \"service\",
\"parameters\": {
\"name\": \"TestService$i\",
\"methods\": [\"test1\", \"test2\"]
}
}" &
done
Error Handling
Missing Required Fields
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-d '{
"type": "service"
}'
Invalid Service Type
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-d '{
"type": "invalidType",
"parameters": {
"name": "Test",
"methods": ["test"]
}
}'
Generate Authentication Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-auth-service" \
-d '{
"type": "service",
"parameters": {
"name": "AuthenticationService",
"methods": [
"login",
"logout",
"refreshToken",
"validateSession",
"changePassword",
"resetPassword",
"generateTwoFactorCode",
"verifyTwoFactorCode",
"revokeToken",
"updateProfile"
]
}
}'
Enterprise Service
Generate Enterprise Service
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-enterprise-scale" \
-d '{
"type": "service",
"parameters": {
"name": "EnterpriseService",
"methods": [
"initializeSystem",
"validateConfiguration",
"processRequest",
"handleResponse",
"manageCaching",
"optimizePerformance",
"handleFailover",
"processQueue",
"validateSecurity",
"manageResources"
]
}
}'
Missing Parameters
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-missing-params" \
-d '{
"type": "service"
}'
Expected Response:
{
"success": false,
"error": "Missing required fields: type or parameters",
"metadata": {
"requestId": "test-missing-params",
"timestamp": "2025-01-28T...",
"duration": "0.04ms"
}
}
Edge Cases
Edge Cases
curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-unicode" \
-d '{
"type": "service",
"parameters": {
"name": "TestService💫",
"methods": ["test✨", "validate🔍", "process🔄"]
}
}'
Load Testing Example
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\"]
}
}" &
done
wait
Changelog (v1.0.36)
- 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
Comprehensive 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 a well-structured backend 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 comprehensive 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
With WebSocket support (ws), developers can 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
Usage
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)
Use Cases
- 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');
// Optimize code
const code = 'const x = 1; console.log( x);';
const optimizedCode = optimizeCode(code);
console.log('Optimized Code:', optimizedCode);
// Manage dependencies
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 run test:all`;
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.
generateEgg(description, type, options) {
const code = this.henFarm.generateCode(type, options);
const newEgg = {
id: this.eggs.length + 1,
description: this.generateDescription(type, options),
type,
code,
createdAt: new Date()
};
this.eggs.push(newEgg);
return newEgg;
}
generateEgg(description, type, options) {
const code = this.henFarm.generateCode(type, options);
const newEgg = {
id: this.eggs.length + 1,
description: this.generateDescription(type, options),
type,
code,
createdAt: new Date()
};
this.eggs.push(newEgg);
return newEgg;
}
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.
API Endpoint
POST /api/generate-egg
Generate a new egg with a custom type and parameters.
Request Body (JSON)
cd eggs-generator pnpm install pnpm dev
in another terminal
curl -X POST http://localhost:3003/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "golden-egg",
"description": "A rare legendary egg",
"parameters": {"size": "large", "color": "gold"}
}'
curl -X POST http://localhost:3003/api/generate-egg \
-H "Content-Type: application/json" \
-d '{
"type": "mystic-egg",
"description": "A magical egg with unknown powers",
"parameters": {"size": "medium", "color": "purple"}
}'
{
"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"
}
}
pnpm install
pnpm dev
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
~/Bleu.js on main *4 +10 !1 pnpm test ✔ 3.1.0 at 03:19:23 PM
> [email protected] test /Users/Bleu.js
> jest --detectOpenHandles --forceExit
PASS lint output/html-report/jest-html-reporters-attach/index/index.js
✓ ESLint (1569 ms)
PASS lint output/jest-html-reporters-attach/report/index.js
✓ ESLint (1370 ms)
PASS lint output/jest-html-reporters-attach/test-report/index.js
✓ ESLint (1201 ms)
PASS lint output/jest-html-reporters-attach/test-report/result.js
✓ ESLint (547 ms)
PASS lint src/backend/src/ai/decisionTree.js
✓ ESLint (7 ms)
PASS lint eggs-generator/coverage/prettify.js
✓ ESLint (23 ms)
PASS lint coverage/prettify.js
✓ ESLint (18 ms)
PASS lint output/lcov-report/prettify.js
✓ ESLint (14 ms)
PASS lint output/html-report/jest-html-reporters-attach/index/result.js
✓ ESLint (16 ms)
PASS lint coverage/lcov-report/prettify.js
✓ ESLint (13 ms)
PASS lint output/prettify.js
✓ ESLint (14 ms)
PASS lint eggs-generator/coverage/lcov-report/prettify.js
✓ ESLint (12 ms)
PASS lint src/backend/src/controllers/apiController.js
✓ ESLint (6 ms)
PASS lint coverage/lcov-report/sorter.js
✓ ESLint (5 ms)
PASS lint dependency-management/src/index.js
✓ ESLint (3 ms)
PASS lint eggs-generator/src/HenFarm.js
✓ ESLint (1 ms)
PASS lint eggs-generator/src/Bleu.js
✓ ESLint (4 ms)
PASS lint eggs-generator/coverage/lcov-report/sorter.js
✓ ESLint (4 ms)
PASS lint src/backend/src/routes/dataRoutes.js
✓ ESLint (3 ms)
PASS lint src/backend/routes.js
✓ ESLint (3 ms)
PASS lint src/backend/index.js
✓ ESLint (4 ms)
PASS lint coverage/sorter.js
✓ ESLint (3 ms)
PASS lint coverage/block-navigation.js
✓ ESLint (3 ms)
PASS lint output/jest-html-reporters-attach/report/result.js
✓ ESLint (3 ms)
PASS lint src/backend/src/services/aiService.js
✓ ESLint (2 ms)
PASS lint src/backend/src/routes/index.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/CustomSequencer.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/aiService.test.js
✓ ESLint (1 ms)
PASS lint dependency-management/src/dependencyManager.js
✓ ESLint (2 ms)
PASS lint output/sorter.js
✓ ESLint (4 ms)
PASS lint output/lcov-report/sorter.js
✓ ESLint (3 ms)
PASS lint eggs-generator/coverage/sorter.js
✓ ESLint (4 ms)
PASS lint frontend/src/index.js
✓ ESLint (3 ms)
PASS lint frontend/public/app.js
✓ ESLint (4 ms)
PASS lint src/backend/src/controllers/dataController.js
✓ ESLint (2 ms)
PASS lint src/backend/src/ai/nlpProcessor.js
✓ ESLint (2 ms)
PASS lint src/backend/src/ml/modelManager.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/decisionTree.test.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/apiGenerateEgg.test.js
✓ ESLint (4 ms)
PASS lint src/backend/tests/seedDatabase.test.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/testSequencer.test.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/apiController.test.js
✓ ESLint (1 ms)
PASS lint src/backend/mocks/AiQuery.js
✓ ESLint (1 ms)
PASS lint language-plugins/javascript/src/index.js
✓ ESLint (1 ms)
PASS lint language-plugins/javascript/src/JSProcessor.js
✓ ESLint (3 ms)
PASS lint language-plugins/javascript/tests/index.test.js
✓ ESLint (1 ms)
PASS lint coverage/lcov-report/block-navigation.js
✓ ESLint (1 ms)
PASS lint ./.simple-git-hooks.js
✓ ESLint (1 ms)
PASS lint dependency-management/test.js
✓ ESLint (2 ms)
PASS lint ./manualConnectionTest.js
✓ ESLint (2 ms)
PASS lint output/lcov-report/block-navigation.js
✓ ESLint (1 ms)
PASS lint ./eslint.generated.config.js
✓ ESLint (3 ms)
PASS lint eggs-generator/src/generateEgg.js
✓ ESLint (1 ms)
PASS lint eggs-generator/coverage/block-navigation.js
✓ ESLint (1 ms)
PASS lint eggs-generator/tests/index.js
✓ ESLint (1 ms)
PASS lint eggs-generator/__mocks__/HenFarm.js
✓ ESLint (2 ms)
PASS lint code-quality-assurance/src/index.js
✓ ESLint (1 ms)
PASS lint src/backend/src/services/seedDatabase.js
✓ ESLint
PASS lint src/backend/src/services/mockEngine.js
✓ ESLint
PASS lint src/backend/src/services/rulesEngine.js
✓ ESLint (2 ms)
PASS lint src/backend/src/routes/simpleRoute.js
✓ ESLint (1 ms)
PASS lint src/backend/src/models/userModel.js
✓ ESLint (1 ms)
PASS lint src/backend/src/utils/logger.js
✓ ESLint (1 ms)
PASS lint src/backend/src/utils/testSequencer.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/apiRoutes.test.js
✓ ESLint (2 ms)
PASS lint src/backend/tests/bleu.test.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/setupTests.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/globalSetup.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/aiTests.test.js
✓ ESLint (1 ms)
PASS lint src/backend/tests/globalTeardown.js
✓ ESLint (2 ms)
PASS lint src/backend/swagger.js
✓ ESLint (1 ms)
PASS lint src/backend/html-report/jest-html-reporters-attach/report/result.js
✓ ESLint (6 ms)
PASS lint src/backend/html-report/jest-html-reporters-attach/report/index.js
✓ ESLint (1 ms)
PASS lint language-plugins/src/index.js
✓ ESLint (1 ms)
PASS lint ./eslint.config.js
✓ ESLint (1 ms)
PASS lint scripts/preinstall.js
✓ ESLint (2 ms)
PASS lint ./generateRuleId.js
✓ ESLint (5 ms)
PASS lint collaboration-tools/src/index.js
✓ ESLint (4 ms)
PASS lint ./vite.config.js
✓ ESLint (1 ms)
PASS lint output/block-navigation.js
✓ ESLint (2 ms)
PASS lint eggs-generator/coverage/lcov-report/block-navigation.js
✓ ESLint (2 ms)
PASS lint eggs-generator/jest.setup.js
✓ ESLint (1 ms)
PASS lint ./jest.setup.js
✓ ESLint (1 ms)
PASS lint ./preinstall.js
✓ ESLint
PASS lint ./simple-git-hooks.js
✓ ESLint (1 ms)
PASS lint src/backend/src/models/AiQuery.js
✓ ESLint (1 ms)
PASS lint src/backend/src/utils/lib/Bleu.js
✓ ESLint (1 ms)
PASS lint ./simpleServer.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 **
~/Bleu.js on main *4 +10 !3 ✔ took 8s 3.1.0 at 03:19:33 PM
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) {
// Optimization logic here
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 |
Generate REST Controller
`curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-controller" \
-d '{
"type": "controller",
"parameters": {
"name": "ProductController",
"methods": [
"listProducts",
"getProductDetails",
"createProduct",
"updateProduct",
"deleteProduct",
"searchProducts",
"exportToCsv",
"importFromCsv"
]
}
}' | jq '.'`;
Generate endpoint
`curl -X POST "http://localhost:3001/api/generate-egg" \
-H "Content-Type: application/json" \
-H "X-Request-ID: test-factory" \
-d '{
"type": "factory",
"parameters": {
"name": "PaymentFactory",
"methods": [
"createPaymentProcessor",
"createPaymentGateway",
"createPaymentValidator",
"validatePaymentMethod",
"processTransaction"
]
}
}' | 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 '.'`;
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