Function: writeService()
writeService(
directory): (service,options) =>Promise<void>
Defined in: services.ts:139
Write a Service to EventCatalog.
You can optionally overide the path of the Service.
Parameters
| Parameter | Type |
|---|---|
directory | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
service | Service |
options | { format: "md" | "mdx"; override: boolean; path: string; versionExistingContent: boolean; } |
options.format? | "md" | "mdx" |
options.override? | boolean |
options.path? | string |
options.versionExistingContent? | boolean |
Returns
Promise<void>
Example
import utils from '@eventcatalog/utils';
const { writeService } = utils('/path/to/eventcatalog');
// Write a Service
// Service would be written to services/InventoryService
await writeService({
id: 'InventoryService',
name: 'Inventory Service',
version: '0.0.1',
summary: 'Service that handles the inventory',
markdown: '# Hello world',
});
// Write a service to the catalog but override the path
// Service would be written to services/Inventory/InventoryService
await writeService({
id: 'InventoryService',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { path: "/Inventory/InventoryService"});
// Write a service to the catalog and override the existing content (if there is any)
await writeService({
id: 'InventoryService',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { override: true });
// Write a service to the catalog and version the previous version
// only works if the new version is greater than the previous version
await writeService({
id: 'InventoryService',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { versionExistingContent: true });