forked from uzinfocom-org/webhook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
22 lines (17 loc) · 676 Bytes
/
mod.ts
File metadata and controls
22 lines (17 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
import triggers from "./middleware/mod.ts";
import server from "./helper/server.ts";
import { Config, Context, EventHandler } from "./hook.ts";
/* Listens to `fetch` events and handles requests from GitHub */
export function webhooks<C extends Context = Context>(config: Config = {}) {
console.log("Listening to the request");
return (...eventHandlers: ReadonlyArray<EventHandler<C>>) => {
addEventListener("fetch", server<C>(config, eventHandlers));
};
}
const config: Config = {
secret: Deno.env.get("WEBHOOK_SECRET") || undefined,
};
// Start the server
await webhooks(config)(...triggers);