-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
61 lines (49 loc) · 1.38 KB
/
types.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { Application } from "./lib/app.ts";
import { Router } from "./lib/router.ts";
import { Context } from "./lib/context.ts";
import type { HTMLRewriter, ParseOptions } from "./lib/deps.ts";
export type Mode = "development" | "debug" | "production";
export type ApplicationOptions = {
rootUrl: URL | string;
router?: Router;
mode: Mode;
};
export type ContextOptions<TApplication> = {
app: TApplication;
request: Request;
};
export type State = {
[key: string]: unknown;
url: URL;
};
export type CompilerOptions = {
mode: Mode;
parserOptions?: ParseOptions;
};
export type CompileOptions = {
input: string;
url: URL;
};
export type RequestHandler<TApplication = Application> = (
context: Context<TApplication>,
) => Promise<unknown> | unknown;
export type Middleware<TApplication = Application> = (
next: RequestHandler<TApplication>,
) => RequestHandler<TApplication>;
export type ResponseTransformer = ((
response: Response,
context: Context,
rewriter: HTMLRewriter,
) => void | Promise<void>);
// deno-lint-ignore no-explicit-any
export type PluginOptions = Record<string, any>;
export interface Register<T = void> {
<Options extends PluginOptions>(
plugin: Plugin<Options>,
options?: Options,
): T;
}
export type Plugin<Options extends PluginOptions = Record<never, never>> = (
instance: Application,
options: Options,
) => Promise<void> | void;