npm package - https://www.npmjs.com/package/@describejs/core
DescribeJS lets you build complete APIs with single route per table in database and lets you call the api endpoints in plain english
Describe your intent β Get an API route instantly.
π Features
-
Natural Language Endpoints β Write route descriptions instead of REST logic
-
Multi-Database Support β MongoDB, PostgreSQL, MySQL, Redis
-
Schema-Driven β Define once, use everywhere
-
Automatic Validation β Built-in data type and rule checking
-
AI-Powered Intent Detection β Maps natural language to CRUD operations
-
Route-Based Architecture β Each route corresponds to a table/entity
npm install @describe/corenpm install @describe/db-mongodb
npm install @describe/db-redisnpm install @describe/db-postgresql
npm install @describe/db-mysqlimport app from '@describe/core';
import mongodbAdapter from '@describe/db-mongodb';
// Register database adapter
app.useDB('mongodb', mongodbAdapter);
// Connect to database
await app.connectDB('mongodb', {
uri: 'mongodb://localhost:27017/myapp'
});
// Define routes with schemas
const user = app.route('/user', {
username: 'string',
email: 'string',
age: 'number'
}, (data) => {
// Optional validation function
if (data.age < 18) throw new Error('Must be 18+');
});
// Start server
app.listen(3000);All operations go through POST /{route}/query endpoints:
POST http://localhost:3000/user/query
{
"query": "create a new user",
"body": {
"username": "john",
"email": "[email protected]",
"age": 25
}
}POST http://localhost:3000/user/query
{
"query": "get user by username",
"body": {
"username": "john"
}
}POST http://localhost:3000/user/query
{
"query": "update user email",
"body": {
"username": "john",
"email": "[email protected]"
}
}POST http://localhost:3000/user/query
{
"query": "delete user",
"body": {
"username": "john"
}
}// User table
const user = app.route('/user', {
username: 'string',
email: 'string',
age: 'number'
});
// Orders table
const orders = app.route('/order', {
userId: 'number',
amount: 'number',
status: 'string'
});
// Products table
const products = app.route('/product', {
name: 'string',
price: 'number',
category: 'string'
});The AI understands various ways to express the same operation:
CREATE Operations:
- "create a new user"
- "add user"
- "register user"
- "insert user"
READ Operations:
- "get user by username"
- "find user"
- "search for user"
- "retrieve user data"
UPDATE Operations:
- "update user email"
- "modify user"
- "change user data"
- "edit user"
DELETE Operations:
- "delete user"
- "remove user"
- "destroy user account"
import mongodbAdapter from '@describe/db-mongodb';
app.useDB('mongodb', mongodbAdapter);
await app.connectDB('mongodb', {
uri: 'mongodb://localhost:27017/myapp'
});import postgresqlAdapter from '@describe/db-postgresql';
app.useDB('postgresql', postgresqlAdapter);
await app.connectDB('postgresql', {
host: 'localhost',
port: 5432,
database: 'myapp',
user: 'postgres',
password: 'password'
});import mysqlAdapter from '@describe/db-mysql';
app.useDB('mysql', mysqlAdapter);
await app.connectDB('mysql', {
host: 'localhost',
port: 3306,
database: 'myapp',
user: 'root',
password: 'password'
});import redisAdapter from '@describe/db-redis';
app.useDB('redis', redisAdapter);
await app.connectDB('redis', {
url: 'redis://localhost:6379'
});const user = app.route('/user', {
username: 'string',
email: 'string',
age: 'number'
}, (data) => {
// Custom validation logic
if (data.username.length < 3) {
throw new Error('Username must be at least 3 characters');
}
if (!data.email.includes('@')) {
throw new Error('Invalid email format');
}
if (data.age < 18) {
throw new Error('Must be 18 or older');
}
});const product = app.route('/product', {
name: 'string', // String type
price: 'number', // Number type
inStock: 'boolean', // Boolean type
tags: 'array', // Array type
metadata: 'object' // Object type
});// Connect to multiple databases
await app.connectDB('mongodb', { uri: 'mongodb://localhost:27017/users' });
await app.connectDB('postgresql', {
host: 'localhost',
database: 'orders',
user: 'postgres',
password: 'password'
});All API responses follow this structure:
{
"success": true,
"operation": "CREATE",
"confidence": 0.95,
"message": "Record created successfully",
"data": {
"id": 123,
"username": "john",
"email": "[email protected]",
"age": 25
},
"table": "user"
}Error responses:
{
"success": false,
"error": "Validation failed",
"details": ["Field 'age' must be a number, got string"],
"table": "user"
}Run the test suite:
node test.jsRun the example server:
node example.js- Each route represents a database table/entity
- Routes are defined with schemas and optional validation
- Each route gets its own
/queryendpoint
- Natural language processing maps queries to CRUD operations
- Keyword-based scoring system with confidence levels
- Extensible preset system for different operation types
- Unified interface for different database types
- Automatic query generation based on database type
- Connection pooling and transaction support
- Predefined templates for CREATE, READ, UPDATE, DELETE operations
- Database-specific query generation
- Customizable response messages
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details
Made with β€οΈ for developers who want to focus on business logic, not API boilerplate!