Skip to content

Events

API Maker supports system events and custom events with N number of listeners.

  • Frontend or other applications can dynamically register/unregister for websocket events.
  • One event can trigger another event and that event can trigger another event, This is supported with N number of depth without creating an infinite call cycle.

Create event

Event listener

API Maker supports adding N number of listeners to system-defined events such as,

  • Auto-generated API hit
  • Custom API hit
  • System API hit
  • Third-party API hit

Triggers

As per the figure, you may enable "Automatic Trigger On API Hit" at the time of event execution.

After enabling auto trigger you can add multiple APIs as per the figure.

Event logs

  • Set log profile to get event listeners' logs.

Global object 'g'

  • Event listener code has support global object 'g'. API Maker users can use all methods of 'g' in the listener's code.
import * as T from 'types';
async function main(g: T.IAMGlobal) {
    return await g.sys.db.getAll({
        instance: "INSTANCE_NAME",
        collection: "COLLECTION_NAME",
        database: "DATABASE_NAME",
    });
};
module.exports = main;