Introduces src/lib/logger.ts emitting JSON lines (level, message, data) compatible with Cloudflare Logpush. Replaces all console.log/warn/error calls in email-processor.ts, index.ts, and hub.ts with structured logger calls. Extracts waitUntilSafe into src/utils/worker.ts to avoid duplicating the executionCtx guard across routes. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
11 lines
349 B
TypeScript
11 lines
349 B
TypeScript
import { Context } from "hono";
|
|
|
|
/** Calls ctx.waitUntil() without throwing when the ExecutionContext is absent (e.g. Node tests). */
|
|
export function waitUntilSafe(c: Context, promise: Promise<unknown>): void {
|
|
try {
|
|
c.executionCtx.waitUntil(promise);
|
|
} catch {
|
|
// ExecutionContext unavailable in Node test environment — ignore.
|
|
}
|
|
}
|