Skip to main content

addMessageToService

Callable

  • addMessageToService(directory: string): (id: string, direction: string, event: { id: string; version: string }, version?: string) => Promise<void>

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

    Optionally specify a version to add the event 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 { addEventToService, addCommandToService } = utils('/path/to/eventcatalog');

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

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