import { initSchedule } from "./schedule" import genContext from "./utils/genContext" initSchedule() Bun.serve({ async fetch(req) { const ctx = await genContext(req) const { path, genResp, logger } = ctx if (path.exact("/")) { logger.info(`${req.method} ${req.url}`) logger.debug(`req body: ${ctx.text}`) } // 逻辑处理 try { // 健康检查 if (path.full("/health")) return genResp.healthCheck() // 其他 return genResp.healthCheck("hello, there is egg, glade to serve you!") } catch (error: any) { // 错误处理 logger.error(error.message) return genResp.serverError(error.message || "server error") } }, port: 3000, })