Skip to main content

addMessageToChannel

Callable

  • addMessageToChannel(directory: string, collection: string): (id: string, _message: { id: string; parameters?: {}; version: string }, version?: string) => Promise<void>

  • Add an event/command/query to a channel by it's id.

    Optionally specify a version to add the message to a specific version of the service.

    @example
    import utils from '@eventcatalog/utils';

    // Adds an event to the service or command to the service
    const { addEventToChannel, addCommandToChannel, addQueryToChannel } = utils('/path/to/eventcatalog');

    // Adds a new event (InventoryUpdatedEvent) that the InventoryService will send
    await addEventToChannel('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
    * // Adds a new event (OrderComplete) that the InventoryService will receive
    await addEventToChannel('InventoryService', 'receives', { event: 'OrderComplete', version: '1.0.0' });

    // Adds a new command (UpdateInventoryCommand) that the InventoryService will send
    await addCommandToChannel('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
    // Adds a new command (VerifyInventory) that the InventoryService will receive
    await addCommandToChannel('InventoryService', 'receives', { command: 'VerifyInventory', version: '1.0.0' });

    // Adds a new query (GetInventoryQuery) that the InventoryService will send
    await addQueryToChannel('InventoryService', 'sends', { query: 'GetInventoryQuery', version: '2.0.0' });
    // Adds a new query (GetOrder) that the InventoryService will receive
    await addQueryToChannel('InventoryService', 'receives', { query: 'GetOrder', version: '1.0.0' });