import type { ApiRequest, ApiResponse } from '../_lib/types.js' // Telegram webhook endpoint // In production, the bot process handles updates via grammY's built-in webhook support // This endpoint serves as a passthrough for webhook mode async function handler(req: ApiRequest, res: ApiResponse) { if (req.method !== 'POST') { return res.status(405).json({ error: 'Method not allowed' }) } // Verify webhook secret const secret = req.headers['x-telegram-bot-api-secret-token'] if (secret !== process.env.BOT_WEBHOOK_SECRET) { return res.status(401).json({ error: 'Invalid secret' }) } // The bot process will handle updates directly in webhook mode // This is a placeholder for when we integrate webhook into the server console.log('Received Telegram webhook update') return res.status(200).json({ ok: true }) } export default handler