/
types.ts
76 lines (67 loc) · 1.85 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
export interface AlephRuntime {
env: Record<string, string>
__version: string
__appRoot: string
__buildID: string
}
export interface SSROptions {
readonly fallback?: string // default is 404.html
readonly include?: RegExp[]
readonly exclude?: RegExp[]
}
export interface Config {
readonly srcDir: string
readonly outputDir: string
readonly baseUrl: string
readonly defaultLocale: string
readonly locales: string[]
readonly ssr: boolean | SSROptions
readonly buildTarget: string
readonly sourceMap: boolean
readonly env: Record<string, string>
readonly importMap: {
imports: Record<string, string>
}
}
export interface APIRequestURL {
readonly pathname: string
readonly params: ReadonlyMap<string, string>
readonly query: URLSearchParams
}
export interface APIRequest {
readonly url: APIRequestURL
readonly method: string
readonly proto: string
readonly protoMinor: number
readonly protoMajor: number
readonly headers: Headers
readonly cookies: ReadonlyMap<string, string>
}
export interface APIResponse {
status(code: number): this
addHeader(key: string, value: string): this
setHeader(key: string, value: string): this
removeHeader(key: string): this
send(data: string | Uint8Array | ArrayBuffer): Promise<void>
json(data: any): Promise<void>
}
export interface APIHandle {
(req: APIRequest, res: APIResponse): void
}
export interface Module {
readonly id: string
readonly hash: string
readonly asyncDeps?: { url: string, hash: string }[]
}
export interface Route {
path: string
module: Module
children?: Route[]
}
export interface RouterURL {
readonly locale: string
readonly pathname: string
readonly pagePath: string
readonly params: Record<string, string>
readonly query: URLSearchParams
}