File
Blob: types/defines/pages.d.ts
| 1 | type Params<P extends string = any> = Record<P, string | string[]>; |
| 2 | |
| 3 | type EventContext<Env, P extends string, Data> = { |
| 4 | request: Request<unknown, IncomingRequestCfProperties<unknown>>; |
| 5 | functionPath: string; |
| 6 | waitUntil: (promise: Promise<any>) => void; |
| 7 | passThroughOnException: () => void; |
| 8 | next: (input?: Request | string, init?: RequestInit) => Promise<Response>; |
| 9 | env: Env & { ASSETS: { fetch: typeof fetch } }; |
| 10 | params: Params<P>; |
| 11 | data: Data; |
| 12 | }; |
| 13 | |
| 14 | type PagesFunction< |
| 15 | Env = unknown, |
| 16 | Params extends string = any, |
| 17 | Data extends Record<string, unknown> = Record<string, unknown> |
| 18 | > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>; |
| 19 | |
| 20 | type EventPluginContext<Env, P extends string, Data, PluginArgs> = { |
| 21 | request: Request<unknown, IncomingRequestCfProperties<unknown>>; |
| 22 | functionPath: string; |
| 23 | waitUntil: (promise: Promise<any>) => void; |
| 24 | passThroughOnException: () => void; |
| 25 | next: (input?: Request | string, init?: RequestInit) => Promise<Response>; |
| 26 | env: Env & { ASSETS: { fetch: typeof fetch } }; |
| 27 | params: Params<P>; |
| 28 | data: Data; |
| 29 | pluginArgs: PluginArgs; |
| 30 | }; |
| 31 | |
| 32 | type PagesPluginFunction< |
| 33 | Env = unknown, |
| 34 | Params extends string = any, |
| 35 | Data extends Record<string, unknown> = Record<string, unknown>, |
| 36 | PluginArgs = unknown |
| 37 | > = ( |
| 38 | context: EventPluginContext<Env, Params, Data, PluginArgs> |
| 39 | ) => Response | Promise<Response>; |
| 40 | |
| 41 | declare module "assets:*" { |
| 42 | export const onRequest: PagesFunction; |
| 43 | } |