-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
147 lines (121 loc) · 3.3 KB
/
index.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import * as Validator from "fastest-validator";
import * as Koa from "koa";
import {DecoratorRepository} from "../decorator";
import * as bodyParser from 'koa-bodyparser';
export interface FireValidatorErrorType {
message: string;
details: Validator.ValidationError[]
}
export type KoaMiddleware = (ctx: Context, next: Koa.Next) => Promise<void>;
export interface SyncCheckFunction extends Validator.SyncCheckFunction {}
export interface Context extends Koa.Context { }
export enum InterceptorType {
WRAP, // 普通拦截器
RULE, // 验证拦截器
}
export interface InterceptorArrayInterface {
controller: Function;
propertyKey: string;
type: InterceptorType;
data?: any
}
export interface DecoratorStoreRouterInterFace {
path: string;
controller: Function;
method: string;
propertyKey: string;
description?: string;
}
export interface DecoratorDocDesInterFace {
propertyKey: string;
description: string;
}
export interface CreateSchemaInterFace {
jsonRule: object;
v: Validator.SyncCheckFunction
}
export interface FireDocumentStoreInterFace {
path: string;
context: DecoratorRepository;
target: any;
}
export interface FireDocumentHeadInterFace {
title?: string;
version?: string | number;
date?: string | Date;
description?: string;
}
export interface FireDocumentInterFace {
body: FireDocumentBodyInterFace[];
title?: string;
version?: string | number;
date?: string | Date;
description?: string;
}
export interface FireDocumentBodyInterFace {
path: string;
methods: string;
rule: any[];
description?: string;
}
export interface FireCatKoaFace {
env?: string | undefined,
keys?: string[] | undefined,
proxy?: boolean | undefined,
subdomainOffset?: number | undefined,
proxyIpHeader?: string | undefined,
maxIpsCount?: number | undefined
}
export interface FireCatFace {
bodyParserConfig?: BodyParserOptions;
koaConfig?: FireCatKoaFace
}
// from @types/koa-bodyparser v4.3.12
export declare function bodyParser(opts?: bodyParser.Options): Koa.Middleware;
export interface BodyParserOptions {
/**
* parser will only parse when request type hits enableTypes, default is ['json', 'form'].
*/
enableTypes?: string[] | undefined;
/**
* requested encoding. Default is utf-8 by co-body
*/
encoding?: string | undefined;
/**
* limit of the urlencoded body. If the body ends up being larger than this limit
* a 413 error code is returned. Default is 56kb
*/
formLimit?: string | undefined;
/**
* limit of the json body. Default is 1mb
*/
jsonLimit?: string | undefined;
/**
* limit of the text body. Default is 1mb.
*/
textLimit?: string | undefined;
/**
* limit of the xml body. Default is 1mb.
*/
xmlLimit?: string | undefined;
/**
* when set to true, JSON parser will only accept arrays and objects. Default is true
*/
strict?: boolean | undefined;
/**
* custom json request detect function. Default is null
*/
detectJSON?: ((ctx: Koa.Context) => boolean) | undefined;
/**
* support extend types
*/
extendTypes?: {
json?: string[] | string | undefined;
form?: string[] | string | undefined;
text?: string[] | string | undefined;
} | undefined;
/**
* support custom error handle
*/
onerror?: ((err: Error, ctx: Koa.Context) => void) | undefined;
}