Write it once
Price rules, formatting, API clients and validation helpers live in one place instead of being copied into every API.
API Maker
The framework for AI era
Your code
Write shared code once and import it everywhere. Run setup code as soon as a sandbox starts.
A utility class is TypeScript that your custom APIs, hooks, events, schedulers and tests import by its path. A process initializer is code that runs when a sandbox starts, before any request, to prepare what your code needs, like a subscription to Redis or MQTT.
Give it a folder path and a unique name, write TypeScript, and export an instance. Interfaces can be exported too.
import * as calc from 'utils/Calculator' (its folder and name) works in custom APIs, hooks, event listeners, schedulers and test cases, with autocompletion in the editor.
Save several versions of a class and activate one. Every importer uses the active version at once.
When a sandbox starts, the active initializers run one after another, in your order and with their own time limit, before it takes any request.
Price rules, formatting, API clients and validation helpers live in one place instead of being copied into every API.
Interfaces exported by a utility class can be used by every importer, and the editor suggests its functions.
Save or activate a version and the sandboxes load the new code, on every server of the cluster.
An initializer can connect to a message broker or a Redis channel and react to its messages, for as long as the sandbox lives.
Shortly after API Maker starts it warms up the sandboxes, so initializers do not wait for the first request.
The checkout API, the invoice scheduler and the order hooks all need the same tax calculation. It lives in a utility class, and when the rate changes you save one new version.
class Calculator { add(x: number, y: number) { return x + y; } multiply(x: number, y: number) { return x * y; }}let temp = new Calculator();export = temp;import * as T from 'types';import * as calc from 'utils/Calculator';async function main(g: T.IAMGlobal) { return { sum: calc.add(3, 6), product: calc.multiply(3, 6) };}module.exports = main;A scheduler runs on its intervals, once in the cluster. An initializer runs once in every new sandbox, without any trigger, to set that sandbox up.
Yes, when the importer passes it: call your functions with g from the custom API, hook or scheduler that uses them.
Documentation