-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.ts
51 lines (42 loc) · 1.06 KB
/
dev.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import "$std/dotenv/load.ts";
import { Some } from "monads";
import handler, { buildURL } from "~/main.ts";
export const env = {
ENV_BOT_SECRET: Deno.env.get("ENV_BOT_SECRET")!,
ENV_BOT_TOKEN: Deno.env.get("ENV_BOT_TOKEN")!,
PASTEBIN_API_KEY: Deno.env.get("PASTEBIN_API_KEY")!,
};
export const getInfo = async () => {
const url = buildURL("getWebHookInfo", Some({}), env);
console.log(
await (await fetch(url)).json(),
);
};
export const deleteHook = async () => {
const url = buildURL(
"deleteWebHook",
Some({ drop_pending_updates: true }),
env,
);
console.log(
await (await fetch(url)).json(),
);
};
export const setHook = async (newUrl: string) => {
const url = buildURL(
"setWebHook",
Some({
url: newUrl,
drop_pending_updates: true,
secret_token: env.ENV_BOT_SECRET,
}),
env,
);
console.log(
await (await fetch(url)).json(),
);
};
await deleteHook();
await setHook("https://main.xdc-hawk.workers.dev/endpoint");
await getInfo();
await Deno.serve((req) => handler.fetch(req, env)).finished;