feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3

This commit is contained in:
RhenCloud 2026-08-13 17:43:33 +08:00
parent f4959eebf8
commit b139712a91
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
166 changed files with 19790 additions and 5539 deletions

View file

@ -0,0 +1,45 @@
import type { Env } from "../../types";
import { handleTelegramUpdate } from "./commands";
const MAX_BODY_SIZE = 1024 * 1024;
function timingSafeEqual(a: string, b: string): boolean {
if (a.length !== b.length) return false;
let diff = 0;
for (let i = 0; i < a.length; i++) {
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
}
return diff === 0;
}
/** Handle a POST to the Telegram webhook endpoint. */
export async function handleTelegramWebhookRequest(request: Request, env: Env): Promise<Response> {
const contentLength = Number(request.headers.get("content-length") ?? 0);
if (contentLength > MAX_BODY_SIZE) {
return new Response("Request too large", { status: 413 });
}
const secret = env.TELEGRAM_WEBHOOK_SECRET;
if (secret) {
const token = request.headers.get("X-Telegram-Bot-Api-Secret-Token");
if (!token || !timingSafeEqual(token, secret)) {
return new Response("Invalid secret", { status: 401 });
}
}
const rawBody = await request.text();
if (rawBody.length > MAX_BODY_SIZE) {
return new Response("Request too large", { status: 413 });
}
let update: unknown;
try {
update = JSON.parse(rawBody);
} catch {
return new Response("Invalid JSON", { status: 400 });
}
// Telegram expects a quick 200; process commands in the background.
await handleTelegramUpdate(env, update);
return new Response("ok");
}