Function: addMessageToService()
addMessageToService(
directory): (id,direction,event,version?) =>Promise<void>
Defined in: services.ts:388
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.
Parameters
| Parameter | Type |
|---|---|
directory | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
id | string |
direction | string |
event | { id: string; version: string; } |
event.id | string |
event.version? | string |
version? | string |
Returns
Promise<void>
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' });