/** * Console Cloudflare Workers 入口(生产部署): * fetch -> Hono 应用(前端资产 + 管理 API + OAuth 回调) * scheduled -> Cron Trigger:TTL 清理 + Webhook 重试(docs/09 建议每 15 分钟) */ import { createApp } from "./app.ts"; import type { Env, ScheduledEvent, WorkersExecutionContext } from "./env.ts"; import { runCron } from "./services/cleanup.ts"; import { processDueDeliveries } from "./services/webhook_delivery.ts"; /** # 成员变量: Hono 应用实例 **/ const app = createApp(); /** # 成员变量: Workers 导出(fetch + scheduled) **/ export default { async fetch(request: Request, env: Env, ctx: WorkersExecutionContext): Promise { return app.fetch(request, env, ctx as never); }, async scheduled(event: ScheduledEvent, env: Env, ctx: WorkersExecutionContext): Promise { ctx.waitUntil( runCron(env, () => processDueDeliveries(env)).then((stats) => { console.log(JSON.stringify({ t: new Date().toISOString(), lvl: "info", msg: "cron", ...stats })); }), ); }, };