/// import { HttpStatus } from "./status"; import { ResponseData } from "./util/response"; import { CloudflareEventFunctions } from "./application"; export declare type ErrorProperties = object; export declare type Params = Record | {}; export declare type HeadersShorthands = { /** * Convenience shorthand for headers.get */ get: typeof Headers.prototype.get; /** * Convenience shorthand for headers.set */ set: typeof Headers.prototype.set; /** * Convenience shorthand for headers.has */ has: typeof Headers.prototype.has; }; export declare class Context, ParamsType = {}, ContextDataType = any> { readonly event: CloudflareEventFunctions & Record; request: Request & HeadersShorthands; url: URL; env: EnvironmentType; /** * The values that are extracted from the url path. * * Example for route: * `"/my-route/:username/:post"` * this would be an object like * * ``` * {username: string, post: string} * ``` * * WARNING: This value has to be set into the context, this is typically done by a router. */ params: ParamsType; /** * The response data, from its fields the final `Response` is constructed. */ response: ResponseData; /** * The recommended namespace for passing information through middleware and to your frontend views. */ data: ContextDataType; /** * The Durable Object state. * */ state: DurableObjectState; constructor(opts: { event: CloudflareEventFunctions; request: Request; env: EnvironmentType; state?: DurableObjectState; }); waitUntil(promise: Promise): void; /** * Throw an error with `status` (default 500) and * `msg`. Note that these are user-level * errors, and the message may be exposed to the client. * * Examples: *``` * this.throw(403) * this.throw(400, 'name required') * this.throw('something exploded') * this.throw(new Error('invalid')) * this.throw(400, new Error('invalid')) * ``` * * See: https://github.com/jshttp/http-errors */ throw(statusOrError: HttpStatus | string | Error, message?: string | Error, props?: object): void; assert: typeof import("./util/assert").assertFunc; } /** * Drop in replacement for `Context` that is strict when it comes to user data (defaulting to an empty object instead of `any`). */ export declare class StrictContext extends Context { }