27 lines
730 B
TypeScript
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}`); |