Skip to content

Instantly share code, notes, and snippets.

@Mathspy
Created December 25, 2021 15:00
Show Gist options
  • Save Mathspy/4b2a32104f21dd0b1c49fa0e53ed94da to your computer and use it in GitHub Desktop.
Save Mathspy/4b2a32104f21dd0b1c49fa0e53ed94da to your computer and use it in GitHub Desktop.
Deno types for CloudFlare Workers
interface ExecutionContext {
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
}
interface ExportedHandler<Env = unknown> {
fetch?: ExportedHandlerFetchHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
}
declare type ExportedHandlerFetchHandler<Env = unknown> = (request: Request, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
declare type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
interface ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment