Telegram Bot + Mini App for city walking quests. - React 19 + TypeScript + Vite 6 frontend - Express 5 + PostgreSQL backend - grammY Telegram bot with DeepSeek AI - GitLab CI/CD: lint, build, deploy to production Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
869 B
TypeScript
25 lines
869 B
TypeScript
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
|