-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.d.ts
102 lines (102 loc) · 3.3 KB
/
http.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/// <reference types="node" />
import { IncomingMessage, Server, ServerResponse } from "http";
import "reflect-metadata";
export interface IResponse extends ServerResponse {
return(status?: number, message?: Object): void;
}
export interface IParam {
index?: number;
name?: string;
fn: Function;
}
export interface IRoute {
method: number;
middleware: Function[];
name: string;
params: IParam[];
path: string;
service: any;
}
export interface IRequest extends IncomingMessage {
query: any;
body: any;
payload: any;
params: any;
parsed: any;
route: IRoute;
files: any;
next: any;
response: IResponse;
request: IRequest;
}
export interface IReturn {
code: number;
message: object | string | Buffer;
headers?: object;
}
export interface INext {
(data?: object): Function;
}
export declare enum HttpMethodsEnum {
GET = 0,
POST = 1,
PUT = 2,
DELETE = 3,
PATCH = 4,
MIXED = 5
}
export declare enum Constants {
INVALID_ROUTE = "Invalid route",
NO_RESPONSE = "No response",
JSON_RESPONSE = "application/json",
ROUTE_DATA = "route:data"
}
export declare class Http {
server: Server;
routes: any[];
private next;
private middleware;
Controller(path?: string): (target: Function) => void;
use(middleware: Function): void;
listen(port: number): void;
Use(...middlewares: any[]): any;
Route(method: number, path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Param(key?: string): (target: Function, name: string, index: number) => void;
Query(key?: string): (target: Function, name: string, index: number) => void;
Body(key?: string): (target: Function, name: string, index: number) => void;
Response(): (target: Function, name: string, index: number) => void;
Request(): (target: Function, name: string, index: number) => void;
Get(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Post(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Put(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Patch(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Delete(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
Mixed(path: string): (target: any, name: string, descriptor: TypedPropertyDescriptor<any>) => void;
autoload(source: string): void;
private getArguments;
private handleRequest;
private execute;
private run;
private slashed;
private findRoute;
private _return;
private inject;
}
export declare const app: Http;
export declare const Get: any;
export declare const Put: any;
export declare const Post: any;
export declare const Patch: any;
export declare const Delete: any;
export declare const Use: any;
export declare const Mixed: any;
export declare const Route: any;
export declare const Controller: any;
export declare const Autoload: any;
export declare const Body: any;
export declare const Param: any;
export declare const Query: any;
export declare const Req: any;
export declare const Res: any;
export declare const Queries: any;
export declare const Params: any;