webhooks_manager
A webhook manager for Deno with guaranteed delivery and retry policy. You can even restart the server, it is persistent.
How to use
import { WebhooksManager } from "https://deno.land/x/webhooks_manager/mod.ts";
const manager = new WebhooksManager(); //For more than one instance use different namespaces
await manager.addWebhooks([
"https://myrulexample.com",
"https://myrsecondulexample.com",
]);
//Will be delivered to urls "https://myrulexample.com" and "https://myrsecondulexample.com"
const notificationIds = await manager.addNotifications([
{
ids: ["12379128471289"],
event: "product_changed",
extra: { //extra is optional
bar: "foo",
},
},
]);
See type ‘WebhooksManagerOptions’ for all options:
type WebhooksManagerOptions = {
processInterval?: number;
connectionTimeout?: number;
namespace?: string;
retryPolicy?: RetryPolicy; //(object, map tries => delayMS), 1 to N, can't skip numbers, see defaultRetryPolicy example
onWebhookError?: (
notification: Notification,
host: string,
) => Promise<void> | void;
onWebhookSuccess?: (
notification: Notification,
host: string,
) => Promise<void> | void;
onFailedAllAttempts?: (
notification: Notification,
host: string,
) => Promise<void> | void;
deleteOnFailedAllAttempts?: boolean;
};
All imports
import {
Notification, //type
RetryPolicy, //type
WebhooksManager,
WebhooksManagerOptions, //type
} from "https://deno.land/x/webhooks_manager/mod.ts";
About
Author: Henrique Emanoel Viana, a Brazilian computer scientist, enthusiast of web technologies, cel: +55 (41) 99999-4664. URL: https://sites.google.com/site/henriqueemanoelviana
Improvements and suggestions are welcome!