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: {
      bar: "foo",
    },
  },
]);

A webhook runs successfully only if it receives an http status 200. See the “WebhooksManager” class for all other public methods and see type ‘WebhooksManagerOptions’ for all options:

export 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?: (
    e: ExecutionUnit,
  ) => Promise<void> | void;
  onWebhookSuccess?: (
    e: ExecutionUnit,
  ) => Promise<void> | void;
  onFailedAllAttempts?: (
    e: ExecutionUnit,
  ) => Promise<void> | void;
  deleteOnFailedAllAttempts?: boolean;
};

All imports

import {
  ExecutionUnit, //type
  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!