Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
File
import type { Static, TSchema } from 'https://cdn.skypack.dev/@sinclair/typebox@0.25.23?dts'import type { CloudflareRequest } from './CloudflareRequest.d.ts'import type { Context } from './Context.d.ts'
type Contact = | { name?: string; email: string } | { name?: string; email: string }[] | string | string[]
export interface FetchContext< ParsedBody = unknown, ParsedQuery = unknown, ParsedHeaders = unknown, ParsedCookies = unknown, ParsedParameters = unknown> extends Context { data: Record<string, unknown>
error: (errorMessage: | 'Access Denied' | 'Bad Request' | 'Malformed Request' | 'Not Found' | 'Payload Too Large' | 'Service Unavailable' | 'Something Went Wrong' | 'Unauthorized' | 403 | 400 | 405 | 404 | 413 | 503 | 500 | 401 ) => { code: number message: string }
mail: ( options: { subject: string message: string from: { name: string email: string } to: Contact cc?: Contact bcc?: Contact reply?: boolean dkim?: { domain?: string privateKey?: string selector?: string } wait?: boolean } ) => Promise<void>
req: { raw: () => CloudflareRequest body: ParsedBody extends TSchema ? Static<ParsedBody> : ParsedBody query: ParsedQuery extends TSchema ? Static<ParsedQuery> : ParsedQuery headers: ParsedHeaders extends TSchema ? Static<ParsedHeaders> : ParsedHeaders cookies: ParsedCookies extends TSchema ? Static<ParsedCookies> : ParsedCookies parameters: ParsedParameters extends TSchema ? Static<ParsedParameters> : ParsedParameters geo: { ip: string city?: string region?: string country?: string continent?: string regionCode?: string latitude?: string longitude?: string postalCode?: string timezone?: string datacenter?: string } userAgent: () => { browser: { name?: string version?: string }, cpu: { architecture?: string }, device: { model?: string type?: string vendor?: string }, engine: { name?: string version?: string }, os: { name?: string version?: string } } | undefined buffer: () => Promise<ArrayBuffer> blob: () => Promise<Blob> formData: () => Promise<FormData> stream: () => ReadableStream<Uint8Array> | undefined }
res: { code: (code: number) => void cookie: ( name: string, value: string, options?: { expiresAt?: Date maxAge?: number domain?: string path?: string secure?: boolean httpOnly?: boolean sameSite?: 'strict' | 'lax' | 'none' } ) => void header: (name: string, value: string) => void html: (data: string, code?: number) => void json: (data: Record<string, unknown>, code?: number) => void text: (data: string, code?: number) => void redirect: (destination: string, code?: number) => void formData: (data: FormData, code?: number) => void blob: (data: Blob, code?: number) => void stream: (data: ReadableStream<Uint8Array>, code?: number) => void buffer: (data: ArrayBuffer | Uint8Array, code?: number) => void }}