Package Exports
- flow-api-engine
- flow-api-engine/dist/index.js
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 (flow-api-engine) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Flow API Engine
A lightweight Node.js library to execute dependency-aware API workflows using a single declarative flow definition.
Flow API Engine allows developers to define and execute multi-step API calls (with dependencies and data passing) in one flow, instead of manually chaining multiple REST calls.
๐ฆ Installation
npm install @your-username/flow-api-engineReplace
@your-usernamewith your actual npm scope.
๐ค Why Flow API Engine?
Traditional REST APIs require multiple sequential requests:
Client โ API 1 โ API 2 โ API 3 โ Merge LogicWith Flow API Engine, you define the entire workflow once:
Client โ Flow Definition โ Engine Executes Everythingโ Fewer network calls โ Cleaner client code โ Centralized orchestration
โจ Features
- Dependency-aware execution (DAG based)
- Automatic data passing between APIs
- Declarative JSON flow definition
- HTTP API execution support
- Transform nodes for data processing
- Easy integration with Node.js backends
๐ง Basic Usage
import { FlowEngine } from "@your-username/flow-api-engine";
const engine = new FlowEngine();
const result = await engine.execute({
nodes: {
getUser: {
type: "http",
method: "GET",
url: "https://jsonplaceholder.typicode.com/users/1"
},
extractUser: {
type: "transform",
depends_on: ["getUser"],
script: `
return {
name: context.getUser.name,
email: context.getUser.email
};
`
}
}
});
console.log(result);๐ค Output Example
{
"getUser": {
"id": 1,
"name": "Leanne Graham",
"email": "Sincere@april.biz"
},
"extractUser": {
"name": "Leanne Graham",
"email": "Sincere@april.biz"
}
}๐ Flow Definition Structure
{
"nodes": {
"<nodeId>": {
"type": "http | transform",
"depends_on": ["otherNodeId"],
"method": "GET | POST",
"url": "https://api.example.com",
"body": {},
"script": "JavaScript code"
}
}
}๐ Supported Node Types
1๏ธโฃ HTTP Node
Used to call REST APIs.
{
"type": "http",
"method": "POST",
"url": "https://api.example.com/order",
"body": {
"userId": "{{nodes.getUser.id}}",
"item": "Laptop"
}
}2๏ธโฃ Transform Node
Used to process or merge data from previous nodes.
{
"type": "transform",
"depends_on": ["getUser"],
"script": "return { username: context.getUser.name };"
}๐ Data Passing Between Nodes
Results of previous nodes are automatically available:
Inside transform scripts
context.getUser.nameInside request bodies
"userId": "{{nodes.getUser.id}}"๐งช Example: Dependent POST Requests
engine.execute({
nodes: {
createUser: {
type: "http",
method: "POST",
url: "https://jsonplaceholder.typicode.com/users",
body: { name: "Zubair" }
},
createOrder: {
type: "http",
depends_on: ["createUser"],
method: "POST",
url: "https://jsonplaceholder.typicode.com/posts",
body: {
userId: "{{nodes.createUser.id}}",
product: "Laptop"
}
}
}
});๐งฉ Internal Architecture (For Understanding)
FlowEngine
โโ Flow Validator
โโ Dependency Resolver (DAG)
โโ Context Store
โโ HTTP Node Executor
โโ Transform Executorโ ๏ธ Limitations
- Sequential execution only (parallel execution planned)
- Transform scripts are not sandboxed (trusted input recommended)
- Not designed for long-running workflows
๐ฎ Roadmap
- Parallel node execution
- Retry & timeout policies
- Conditional branching
- Secure transform sandbox
- Visual flow designer
๐ License
MIT License
โญ Summary
Flow API Engine simplifies backend orchestration by allowing developers to define what should happen, not how to chain API calls.
Perfect for:
- Microservices orchestration
- Backend automation
- Complex API workflows