diff --git a/src/index.ts b/src/index.ts index 14348a8..d7d984d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,15 +26,6 @@ import { createStandardResponse } from "./lib/types"; */ const app = new Hono<{ Bindings: Env }>(); -/** - * Worker export configuration - * Defines the main fetch handler and scheduled event handler - */ -export default { - fetch: app.fetch, - scheduled, -}; - /** * Scheduled event handler for periodic maintenance tasks * Executes every 5 minutes as configured in wrangler.jsonc @@ -42,11 +33,11 @@ export default { * @param env Environment bindings * @param ctx Execution context for background tasks */ -async function scheduled( +function scheduled( event: ScheduledEvent, env: Env, ctx: ExecutionContext -): Promise { +): void { ctx.waitUntil(handleScheduled(event, env)); } @@ -61,6 +52,17 @@ async function handleScheduled(event: ScheduledEvent, env: Env): Promise { clearMemoryCache(); } +/** + * Worker export configuration + * Defines the main fetch handler and scheduled event handler + */ +const worker = { + fetch: app.fetch, + scheduled, +}; + +export default worker; + /** * API Route Definitions * Defines all available endpoints and their handlers