feat: 接口改为返回JSON
All checks were successful
CI Monitor CI/CD / build-image (push) Successful in 22s
CI Monitor CI/CD / deploy (push) Successful in 24s

This commit is contained in:
zhaoyingbo 2024-03-08 19:15:14 +08:00
parent f25c9aaa37
commit f387806924
2 changed files with 13 additions and 15 deletions

View File

@ -97,24 +97,22 @@ const getProjDiffInfo = async () => {
return group.slice(0, 5); return group.slice(0, 5);
}; };
const sendRobotMsg = async () => { const getRobotMsg = async () => JSON.stringify({
const msgContent = { type: "template",
type: "template", data: {
data: { template_id: "ctp_AAyVLS6Q37cL",
template_id: "ctp_AAyVLS6Q37cL", template_variable: {
template_variable: { ...(await getNewCicdStatus()),
...(await getNewCicdStatus()), ...(await getStatisticsInfo()),
...(await getStatisticsInfo()), group_table: await getProjDiffInfo(),
group_table: await getProjDiffInfo(),
},
}, },
}; },
})
const res = await service.sendMessage(JSON.stringify(msgContent)); const sendRobotMsg = async () => await service.sendMessage(await getRobotMsg())
console.log(res);
};
const manageRobot = { const manageRobot = {
getRobotMsg,
sendRobotMsg, sendRobotMsg,
}; };

View File

@ -28,7 +28,7 @@ Bun.serve({
async fetch(req) { async fetch(req) {
const url = new URL(req.url); const url = new URL(req.url);
if (url.pathname === '/ci') { if (url.pathname === '/ci') {
await manageRobot.sendRobotMsg(); return Response.json(await manageRobot.getRobotMsg());
} }
return new Response("OK"); return new Response("OK");
}, },