-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
47 lines (39 loc) · 1.09 KB
/
types.d.ts
File metadata and controls
47 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
EventContext,
Response as CFResponse,
} from "@cloudflare/workers-types";
export type PostwareFunction = (
ctx: RewriterContext,
response: Response,
) => Promise<Response | void>;
export type MiddlewareFunction = (
ctx: RewriterContext,
) => Promise<void | Response>;
export type RewriterContext = {
headElements?: Array<Promise<string>> | null;
pageRequest: Promise<Response> | null;
data: Record<string, any>;
flags: Record<string, any>;
clientSideData: Record<string, any>;
postware: Array<PostwareFunction>;
templates: Record<string, Template>;
rules: Array<Rule>;
skip?: boolean;
cfContext: EventContext<any, any, any>;
any: Record<string, any>;
};
export type Rule = (rewriter: HTMLRewriter, ctx: RewriterContext) => void;
export type RewriterFactoryParameters = {
ctx: RewriterContext;
extraRules?: Array<Rule>;
};
export type CommonResponse = CFResponse & Response;
export type Template =
| undefined
| null
| string
| Response
| Promise<string>
| Promise<Response>
| ((context: RewriterContext) => string | Promise<string>);
export {};