From 300336385c7814736952215192f68159f5d596d4 Mon Sep 17 00:00:00 2001 From: shevernitskiy Date: Thu, 12 Oct 2023 09:56:44 +0300 Subject: [PATCH 1/3] support nhhtp as webhook handler --- src/convenience/frameworks.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/convenience/frameworks.ts b/src/convenience/frameworks.ts index 474f1b6e..7aeffd46 100644 --- a/src/convenience/frameworks.ts +++ b/src/convenience/frameworks.ts @@ -340,6 +340,15 @@ const worktop: FrameworkAdapter = (req, res) => ({ unauthorized: () => res.send(401, WRONG_TOKEN_ERROR), }); +/** nhttp web framework */ +const nhttp: FrameworkAdapter = (rev) => ({ + update: rev.body, + header: rev.headers.get(SECRET_HEADER) || undefined, + end: () => rev.response.status(200), + respond: (json) => rev.response.status(200).send(json), + unauthorized: () => rev.response.status(401).send(WRONG_TOKEN_ERROR), +}); + // Please open a PR if you want to add another adapter export const adapters = { express, @@ -359,4 +368,5 @@ export const adapters = { "cloudflare-mod": cloudflareModule, hono, worktop, + nhttp, }; From d127a448b6e7e9f1a7174f20c3741de8700ef7d6 Mon Sep 17 00:00:00 2001 From: shevernitskiy Date: Thu, 12 Oct 2023 10:12:55 +0300 Subject: [PATCH 2/3] fix end() --- src/convenience/frameworks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convenience/frameworks.ts b/src/convenience/frameworks.ts index 7aeffd46..ee7a495a 100644 --- a/src/convenience/frameworks.ts +++ b/src/convenience/frameworks.ts @@ -344,7 +344,7 @@ const worktop: FrameworkAdapter = (req, res) => ({ const nhttp: FrameworkAdapter = (rev) => ({ update: rev.body, header: rev.headers.get(SECRET_HEADER) || undefined, - end: () => rev.response.status(200), + end: () => rev.response.sendStatus(200), respond: (json) => rev.response.status(200).send(json), unauthorized: () => rev.response.status(401).send(WRONG_TOKEN_ERROR), }); From db4687506ce6fee07457db0c604c5b9694e513a4 Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Sat, 14 Oct 2023 11:26:16 +0200 Subject: [PATCH 3/3] style: `deno fmt` --- src/bot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index cf08c226..1ab76137 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -330,7 +330,7 @@ export class Bot< ) { if (this.me === undefined) { throw new Error( -"Bot not initialized! Either call `await bot.init()`, \ + "Bot not initialized! Either call `await bot.init()`, \ or directly set the `botInfo` option in the `Bot` constructor to specify \ a known bot info object.", );