fix: resolve TypeScript build errors
- Use InlineKeyboardMarkup from grammy/types for proper typing - Add QuestEvent interface for event processor - Accept Promise<unknown> in wrapHandler for flexible return types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c61e6ad9cd
commit
cddf96b154
@ -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<string, unknown>[][] } | 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 } } ]] }
|
||||
|
||||
@ -46,7 +46,15 @@ async function processEvents(bot: Bot<BotContext>) {
|
||||
}
|
||||
}
|
||||
|
||||
async function processEvent(bot: Bot<BotContext>, event: Record<string, unknown>) {
|
||||
interface QuestEvent {
|
||||
id: string
|
||||
user_id: string
|
||||
point_id: string | null
|
||||
event_type: string
|
||||
payload: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
async function processEvent(bot: Bot<BotContext>, 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])
|
||||
|
||||
@ -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<void>) {
|
||||
function wrapHandler(handler: (req: Request, res: Response) => Promise<unknown>) {
|
||||
return async (req: Request, res: Response, next: NextFunction) => {
|
||||
const mergedQuery = { ...req.query, ...req.params }
|
||||
Object.defineProperty(req, 'query', {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user