Encrypt, decrypt, hash
Encrypt and decrypt with the algorithm and key of your secret (AES by default, RC4 or TripleDES) or with your own. Hash with HMAC SHA-256.
API Maker
The framework for AI era
Your code
Ready APIs for the jobs every backend has: encryption, secrets, Redis, cache, validation, tokens and events.
API Maker comes with 21 system APIs. Your code calls them with g.sys, and you can open any of them to clients as a REST API under /api/system-api. They have settings and hooks like every other API.
Step through it, slow it down, or open the full canvas.
21 system APIs, ready to use. Encryption, secrets and Redis, cache reset, data validation, events and utilities. Call them as REST APIs, or with g.sys in your code.
Encryption, secrets and Redis, cache reset, data validation, events and utilities. Call them as REST APIs, or with g.sys in your code.
The algorithm and key come from your Secret: AES by default, RC4 or TripleDES. The hash is an HMAC SHA-256, it can not be reversed.
Read any key of your encrypted Secret. Set, read and remove Redis keys with a TTL: OTPs, sessions, locks.
The cache of a table, of a custom API, of system APIs or of third party APIs. You get back how many Redis keys were removed.
The validation of a save runs against the schema of a table, a custom API or a third party API, and every error comes back.
Emit events to their listeners or to WebSockets, get tokens for your users, call external APIs in parallel or in sequence.
Encrypt and decrypt with the algorithm and key of your secret (AES by default, RC4 or TripleDES) or with your own. Hash with HMAC SHA-256.
Read keys of your secret. Get, set and remove Redis keys with a TTL, and set only if absent: OTPs, sessions, locks.
Clear the cache of a table, a custom API or the system APIs. The answer says how many keys were removed.
Run the validation of a table or a custom API on some data and get every error back.
get token signs in API users and the users of your own tables, and returns a token, a refresh token and its expiry.
Call external APIs in parallel or in sequence and pass values from one answer to the next request. Emit events and WebSocket events. Read table metadata, check a connection string, reset the pools of a moved tenant.
import * as T from 'types';async function main(g: T.IAMGlobal) { const otp = String(Math.floor(100000 + Math.random() * 900000)); await g.sys.cache.setKey(`otp:${g.req.body.phone}`, otp, 300); // expires in 5 minutes const smsKey = await g.sys.system.getSecret('sms.apiKey'); const sent = await g.sys.system.callExternalApi({ url: 'https://sms.example.com/v1/messages', method: 'POST', headers: { Authorization: `Bearer ${smsKey}` }, body: { to: g.req.body.phone, text: `Your code is ${otp}` }, }); return { sent: sent.statusCode === 200 };}module.exports = main;POST /api/system-api/admin/hash-datax-am-authorization: <API user token>{ "name": "Joseph" }The answer is the HMAC SHA-256 of the body, in hex, in data.
encrypt-data, decrypt-data, hash-data, token, call-external-api, get-secret-by-name, get-redis-key, set-redis-key, remove-redis-key, the four reset caches (database, custom APIs, system APIs, third party APIs), get-table-meta, emit-event, emit-event-ws, the three is-valid-data checks (table, custom API, third party API), multi-tenant-instance-updated and is-valid-connection-string.
Yes. g.sys.system.executeQuery runs SQL on a SQL instance, or a command on MongoDB.
Yes. Each system API has settings with enableCaching, its access type and auth providers, and pre and post hooks.