forked from alephjs/aleph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
44 lines (40 loc) · 1.49 KB
/
types.d.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
declare type Context = import("./server/types.ts").Context;
declare type Middleware = import("./server/types.ts").Middleware;
declare type ResponseLike =
| Response
| ReadableStream
| ArrayBuffer
| Uint8Array
| string
| Blob
| File
| Record<string, unknown>
| Array<unknown>
| null;
declare interface Data<DataType = ResponseLike, ActionDataType = ResponseLike> {
defer?: boolean;
cacheTtl?: number;
any?(request: Request, context: Context): Promise<Response | void> | Response | void;
get?(request: Request, context: Context): Promise<DataType> | DataType;
post?(request: Request, context: Context): Promise<ActionDataType> | ActionDataType;
put?(request: Request, context: Context): Promise<ActionDataType> | ActionDataType;
patch?(request: Request, context: Context): Promise<ActionDataType> | ActionDataType;
delete?(request: Request, context: Context): Promise<ActionDataType> | ActionDataType;
}
declare const __aleph: {
// deno-lint-ignore no-explicit-any
importRouteModule(url: string): Promise<any>;
// deno-lint-ignore no-explicit-any
getRouteModule(url: string): any;
};
declare interface ImportMeta {
/** Aleph.js HMR `hot` API. */
readonly hot?: {
readonly data: Record<string, unknown>;
accept<T = Record<string, unknown>>(callback?: (module: T) => void): void;
decline(): void;
dispose: (callback: (data: Record<string, unknown>) => void) => void;
invalidate(): void;
watchFile(filename: string, callback: () => void): () => void;
};
}