(platform: string, request: Request)
| 5 | type Platform = keyof typeof bot.webhooks; |
| 6 | |
| 7 | export function handleWebhook(platform: string, request: Request): Response | Promise<Response> { |
| 8 | const handler = bot.webhooks[platform as Platform]; |
| 9 | if (!handler) { |
| 10 | return new Response('Unknown platform', { status: 404 }); |
| 11 | } |
| 12 | |
| 13 | return handler(request, { |
| 14 | waitUntil: task => after(() => task), |
| 15 | }); |
| 16 | } |