gitlab_monitor/index.ts
zhaoyingbo 4c109a006f
All checks were successful
CI Monitor CI/CD / build-image (push) Successful in 31s
CI Monitor CI/CD / deploy (push) Successful in 35s
feat: 抽象定时任务
2024-06-28 10:15:29 +08:00

27 lines
730 B
TypeScript

import manageRobot from "./controllers/manageRobot";
import initSchedule from "./schedule";
// 启动定时任务
initSchedule();
const server = Bun.serve({
async fetch(req) {
const url = new URL(req.url);
if (url.pathname === "/ci") {
const chat_id = url.searchParams.get("chat_id");
console.log("🚀 ~ fetch ~ chat_id:", chat_id);
if (!chat_id)
return new Response("chat_id is required!", { status: 400 });
manageRobot.sendCIReportByChatId(chat_id);
return Response.json({
code: 0,
msg: "success",
data: "reporting...",
});
}
return new Response("OK");
},
port: 3000,
});
console.log(`Listening on ${server.hostname}:${server.port}`);