createWebhooksCore
function createWebhooksCore(options): WebhooksCore;Defined in: src/core.ts:504
Construct the core over the configured storage.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
WebhooksCoreOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { createWebhooksCore } from "@xtandard/webhooks";import { createMemoryStorage } from "@xtandard/webhooks/storage/memory";
const core = createWebhooksCore({ storage: createMemoryStorage() });
await core.createApplication({ key: "acme" });await core.upsertEventType({ name: "invoice.paid" });const endpoint = await core.createEndpoint("acme", { url: "https://api.acme-customer.com/webhooks", eventTypes: ["invoice.paid"],});
// The hot path — call this from your app code:await core.publish("acme", { eventType: "invoice.paid", payload: { invoiceId: "inv_1", amount: 4200 },});