diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..9a2a0e2 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20 diff --git a/api/update.mjs b/api/update.mjs index a4b96aa..2cfb280 100644 --- a/api/update.mjs +++ b/api/update.mjs @@ -1,10 +1,10 @@ -import {webhookStream} from "vercel-grammy"; import {bot, secretToken} from "../src/bot.mjs"; +import {webhookStream} from "vercel-grammy"; export const config = {runtime: "edge"}; // Custom grammY handler for incoming updates via webhooks with streaming response -export default webhookStream(bot, { +export const POST = webhookStream(bot, { timeoutMilliseconds: 59_000, secretToken, }); diff --git a/api/webhook.mjs b/api/webhook.mjs index 53aca5e..afd3b30 100644 --- a/api/webhook.mjs +++ b/api/webhook.mjs @@ -1,11 +1,11 @@ -import {setWebhookCallback} from "vercel-grammy"; import {bot, secretToken} from "../src/bot.mjs"; +import {setWebhookCallback} from "vercel-grammy"; export const config = {runtime: "edge"}; // Handler to set webhook url based on request headers -export default setWebhookCallback(bot, { - secret_token: secretToken, +export const POST = setWebhookCallback(bot, { path: "api/update", - onError: "return" + onError: "return", + secretToken, }); diff --git a/package.json b/package.json index 1167b30..b7b4391 100644 --- a/package.json +++ b/package.json @@ -5,19 +5,15 @@ "license": "MIT", "scripts": { "env": "vercel env pull .env", - "polling": "npm run env && npm run start", - "webhook": "npm run tunnel & vercel dev --listen 3000", - "tunnel": "cloudflared tunnel --url http://localhost:3000", - "start": "node --watch -r dotenv/config scripts/start.mjs" + "build": "node scripts/build.mjs", + "start:dev": "vercel dev --listen 3000", + "start:local": "node --watch --env-file=.env scripts/start.mjs", + "start:tunnel": "npx -y cloudflared tunnel --url http://localhost:3000", + "start:webhook": "npm run start:tunnel & npm run start:dev", + "start:polling": "npm run env && npm run start:local" }, "dependencies": { - "grammy": "^1.19.1", - "vercel-grammy": "^0.2.1" - }, - "devDependencies": { - "dotenv": "^16.3.1" - }, - "engines": { - "node": "^18.0.0" + "grammy": "^1.21.1", + "vercel-grammy": "^1.0.0" } } diff --git a/public/index.html b/public/index.html index 05c750d..6d9712d 100644 --- a/public/index.html +++ b/public/index.html @@ -20,7 +20,7 @@
-