fix: 尽快响应200

This commit is contained in:
tangyanbiao 2021-12-21 15:07:56 +08:00
parent 02e161b97d
commit 838171e62a

View File

@ -34,7 +34,7 @@ function handleMessage(name: string, data: any): string {
return `${name}${action}: ${content}` return `${name}${action}: ${content}`
} }
async function main(req: VercelRequest, res: VercelResponse) { function main(req: VercelRequest, res: VercelResponse) {
if (req.method !== 'POST') { if (req.method !== 'POST') {
res.setHeader('Allow', 'POST') res.setHeader('Allow', 'POST')
return res.status(405).end('Method Not Allowed') return res.status(405).end('Method Not Allowed')
@ -44,10 +44,10 @@ async function main(req: VercelRequest, res: VercelResponse) {
const product = req.query.product.toString() || 'Unknown' const product = req.query.product.toString() || 'Unknown'
const content = handleMessage(product, req.body) const content = handleMessage(product, req.body)
if (bots.indexOf('TELEGRAM') >= 0) { if (bots.indexOf('TELEGRAM') >= 0) {
await sendToTelegram(content) sendToTelegram(content)
} }
if (bots.indexOf('FEISHU') >= 0) { if (bots.indexOf('FEISHU') >= 0) {
await sendToFeishu(content) sendToFeishu(content)
} }
return res.status(200).end('ok') return res.status(200).end('ok')
} catch (e) { } catch (e) {