From cddf96b1547254bd1040fdf0990244d328d85946 Mon Sep 17 00:00:00 2001 From: laruevin Date: Wed, 11 Feb 2026 12:30:56 +0700 Subject: [PATCH] fix: resolve TypeScript build errors - Use InlineKeyboardMarkup from grammy/types for proper typing - Add QuestEvent interface for event processor - Accept Promise in wrapHandler for flexible return types Co-Authored-By: Claude Opus 4.6 --- bot/bot.ts | 3 ++- bot/services/event-processor.ts | 10 +++++++++- server/index.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bot/bot.ts b/bot/bot.ts index 97ebeb4..db69026 100644 --- a/bot/bot.ts +++ b/bot/bot.ts @@ -1,4 +1,5 @@ import { Bot, session } from 'grammy' +import type { InlineKeyboardMarkup } from 'grammy/types' import { conversations, createConversation } from '@grammyjs/conversations' import type { BotContext, SessionData } from './types.js' import { onboardingConversation } from './conversations/onboarding.js' @@ -8,7 +9,7 @@ import { t, getLang } from './i18n/index.js' // Helper: build reply_markup for opening the Mini App // Telegram requires HTTPS for both web_app and url buttons. // In dev (HTTP), we skip the button entirely and append the link to the message text. -function questMarkup(label: string): { inline_keyboard: Record[][] } | undefined { +function questMarkup(label: string): InlineKeyboardMarkup | undefined { const appUrl = process.env.APP_URL || 'https://guidly.example.com' if (appUrl.startsWith('https://')) { return { inline_keyboard: [[ { text: label, web_app: { url: appUrl } } ]] } diff --git a/bot/services/event-processor.ts b/bot/services/event-processor.ts index 5e70fa3..40ddd23 100644 --- a/bot/services/event-processor.ts +++ b/bot/services/event-processor.ts @@ -46,7 +46,15 @@ async function processEvents(bot: Bot) { } } -async function processEvent(bot: Bot, event: Record) { +interface QuestEvent { + id: string + user_id: string + point_id: string | null + event_type: string + payload: Record | null +} + +async function processEvent(bot: Bot, event: QuestEvent) { // Look up the user to get their telegram_id for sending messages const { pool } = await import('../../api/_lib/db.js') const { rows: users } = await pool.query('SELECT * FROM users WHERE id = $1', [event.user_id]) diff --git a/server/index.ts b/server/index.ts index e406652..1668f47 100644 --- a/server/index.ts +++ b/server/index.ts @@ -15,7 +15,7 @@ app.use(express.urlencoded({ extended: true })) app.use(cookieParser()) // Wrap handler to catch errors and merge params -function wrapHandler(handler: (req: Request, res: Response) => Promise) { +function wrapHandler(handler: (req: Request, res: Response) => Promise) { return async (req: Request, res: Response, next: NextFunction) => { const mergedQuery = { ...req.query, ...req.params } Object.defineProperty(req, 'query', {