Function: addMessageToChannel()
addMessageToChannel(
directory,collection): (id,_message,version?) =>Promise<void>
Defined in: channels.ts:233
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.
Parameters
| Parameter | Type |
|---|---|
directory | string |
collection | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
id | string |
_message | { id: string; parameters: {}; version: string; } |
_message.id | string |
_message.parameters? | {} |
_message.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 { 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' });