@ambassify/eventbus-client

API Client for eventbus service

Usage no npm install needed!

<script type="module">
  import ambassifyEventbusClient from 'https://cdn.skypack.dev/@ambassify/eventbus-client';
</script>

README

EventBus-client

A client to publish events to eventbus.

Installation

npm install --save eventbus-client

Usage

const { Client } = require('eventbus-client');
const eventbus = new Client({
    baseUrl: 'https://eventbus-endpoint'
});

eventbus.send('event_name', payload, options);

new EventBus()

new EventBus({ endpoint, [token, tokenType], [timeout] })
  • endpoint: The endpoint of the eventbus service.
  • token: The accessToken to use when none was set for the .send() call.
  • tokenType: The tokenType to use when setting the Authorization headerj.
  • timeout: The duration for which events are batched before publishing them.

.send()

.send(eventName, payload, options)
  • eventName: The event to publish. Example: item_created
  • payload: Any object that can be serialized using JSON.stringify
  • options: An object with any one of the following options set:
    • orgId: The organization ID to publish to.
    • userId: The user ID to publish to.
    • id: The ID of the object in payload
    • type: The type of the object in payload