-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
58 lines (58 loc) · 1.99 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
export type TBody = Uint8Array | Deno.Reader | string;
export type NextFunction = (err?: any) => void;
export interface HttpRequest {
respond: (r: any) => Promise<void>;
pond: (body?: TBody | { [k: string]: any } | null, opts?: PondOptions) => Promise<void>;
proto: string;
url: string;
conn: Deno.Conn;
isHttps: boolean | undefined;
method: string;
headers: Headers;
body: Deno.Reader | null;
originalUrl: string;
params: { [k: string]: any };
_parsedUrl: { [k: string]: any };
path: string;
query: { [k: string]: any };
search: string | null;
getBaseUrl: () => string;
[k: string]: any;
};
export interface HttpResponse {
locals: any;
opts: PondOptions;
header: (key?: { [k: string]: any } | string, value?: any) => this | (this & Headers) | (this & string);
status: (code?: number) => this | (this & number);
type: (contentType: string) => this;
body: (body?: TBody | { [k: string]: any } | null) => Promise<void>;
return: ((body: any) => any)[];
[k: string]: any;
};
export type PondOptions = {
status?: number;
headers?: Headers;
[key: string]: any;
};
export type DeroConfig = {
useParseQuery?: (query: string) => any;
useParseUrl?: (req: HttpRequest) => any;
useNativeHttp?: boolean;
};
export type THandler<
Req extends HttpRequest = HttpRequest,
Res extends HttpResponse = HttpResponse
> = (req: Req, res: Res, next: NextFunction) => any;
export type THandlers<
Req extends HttpRequest = HttpRequest,
Res extends HttpResponse = HttpResponse
> = Array<THandler<Req, Res> | THandler<Req, Res>[]>;
export type DeroRoutersControllers<
Req extends HttpRequest = HttpRequest,
Res extends HttpResponse = HttpResponse
> = {
class?: { new(...args: any): { [k: string]: any } }[] | { new(...args: any): { [k: string]: any } };
wares?: THandler<Req, Res> | THandlers<Req, Res>;
prefix?: string | undefined;
routes?: { [k: string]: any }[];
};