egg_server/index.ts
zhaoyingbo 865308ee31
All checks were successful
Egg CI/CD / build-image (push) Successful in 8m16s
Egg CI/CD / deploy (push) Successful in 7m47s
feat: Update code formatting and fix minor issues
2024-05-05 02:34:16 +00:00

20 lines
580 B
TypeScript

import { manageBotReq } from "./routes/bot";
import { manageMessageReq } from "./routes/message";
import { initSchedule } from "./schedule";
initSchedule()
Bun.serve({
async fetch(req) {
const url = new URL(req.url);
// 根路由
if (url.pathname === "/") return new Response("hello, glade to see you!");
// 机器人
if (url.pathname === '/bot') return await manageBotReq(req);
// 消息发送
if (url.pathname === '/message') return await manageMessageReq(req);
// 其他
return new Response('OK')
},
port: 3000
});