Kvl.InitConfig
interface InitConfig{
port: number | 8080;
baseUrl?: string|''
static?: string
headers?: { [args: string]: string }
https?: {
key: Buffer,
cert: Buffer,
port: number
}
global?: any
router?: Array<Function | { name: Function, enable: boolean }>;
interceptor?: Array<Interceptor> | Interceptor
express?(app: Express.Application): void
getData?:(request: kvl.Response) => void
throw?:(request: ExpressRequest, response: ExpressResponse, status: number, error: Error) => void;
}
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
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
Kvl.Router (@Router)
interface Router{
name?: string;
url?: string;
interceptor?: Array<Interceptor> | Interceptor
interceptorLevel?: 0 | 1 | 2 | 3 | 4
router?: Array<Function | { name: Function, enable: boolean }>;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Kvl.RouterConfig (@config)
interface RouterConfig{
name?: string;
type: Array<string> | string
url: string
interceptor?: Array<Interceptor> | Interceptor
interceptorLevel?: 0 | 1 | 2 | 3 | 4,,
getData?:(request: kvl.Response) => void
validation?: Validation
validType?: 'query' | 'body' | 'param' | 'all'
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Kvl.ValidationError
interface ValidationError {
errorMsg: string,
required: boolean,
name: string,
regular: string,
value: string
type: 'string' | 'number' | 'boolean' | any
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
kvl.RouterTree
interface RouterTree{
children: this[],
class: Function,
name: string
parentId: string
config: kvl.Router,
id: string
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Kvl.Request
interface Request {
//...继承自express
}
1
2
3
2
3
Kvl.Response
interface Response {
//...继承自express
router(path: string, param?: {
query?: { [argv: string]: any },
body?: { [argv: string]: any }
}): any;
parentId: string
id: string
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Kvl.Validation
interface Validation {
done?: any;
[argy: string]: {
type?: 'string' | 'number' | 'boolean' | any,
required?: boolean | false,
name?: string,
regular?: RegExp,
description?: string,
done?: ValidationDone
} | Function | 'string' | 'number' | 'boolean' | boolean | { empty: string, regular: string } | any;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Kvl.ValidationDone
interface ValidationDone {
(err: ValidationError, response: kvl.Response): void
}
1
2
3
2
3
Kvl.Interceptor
interface Interceptor{
(request: kvl.Request, response: kvl.Response): void
}
1
2
3
2
3
Kvl.Injectable
function Injectable(name: string): any
1
Kvl.Global
function Global(): any
1
Kvl.data
function data(): any
1