@eggjs/controller-decorator 4.0.0-beta.35 → 4.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/ControllerMetaBuilderFactory.d.ts +10 -6
- package/dist/builder/ControllerMetaBuilderFactory.js +37 -41
- package/dist/builder/index.d.ts +1 -1
- package/dist/builder/index.js +3 -2
- package/dist/decorator/Acl.d.ts +4 -1
- package/dist/decorator/Acl.js +23 -21
- package/dist/decorator/Context.d.ts +4 -1
- package/dist/decorator/Context.js +15 -10
- package/dist/decorator/Middleware.d.ts +6 -2
- package/dist/decorator/Middleware.js +49 -61
- package/dist/decorator/http/HTTPController.d.ts +6 -2
- package/dist/decorator/http/HTTPController.js +22 -28
- package/dist/decorator/http/HTTPMethod.d.ts +6 -2
- package/dist/decorator/http/HTTPMethod.js +20 -16
- package/dist/decorator/http/HTTPParam.d.ts +152 -166
- package/dist/decorator/http/HTTPParam.js +208 -226
- package/dist/decorator/http/Host.d.ts +6 -2
- package/dist/decorator/http/Host.js +26 -24
- package/dist/decorator/http/index.d.ts +5 -4
- package/dist/decorator/http/index.js +7 -5
- package/dist/decorator/index.d.ts +8 -4
- package/dist/decorator/index.js +10 -5
- package/dist/impl/http/HTTPControllerMetaBuilder.d.ts +13 -8
- package/dist/impl/http/HTTPControllerMetaBuilder.js +58 -55
- package/dist/impl/http/HTTPControllerMethodMetaBuilder.d.ts +15 -10
- package/dist/impl/http/HTTPControllerMethodMetaBuilder.js +80 -96
- package/dist/impl/http/index.d.ts +2 -2
- package/dist/impl/http/index.js +4 -3
- package/dist/impl/index.d.ts +3 -1
- package/dist/impl/index.js +5 -2
- package/dist/index.d.ts +27 -6
- package/dist/index.js +29 -7
- package/dist/model/HTTPControllerMeta.d.ts +24 -21
- package/dist/model/HTTPControllerMeta.js +53 -57
- package/dist/model/HTTPCookies.d.ts +2 -1
- package/dist/model/HTTPCookies.js +3 -2
- package/dist/model/HTTPMethodMeta.d.ts +59 -56
- package/dist/model/HTTPMethodMeta.js +102 -124
- package/dist/model/index.d.ts +3 -3
- package/dist/model/index.js +5 -4
- package/dist/util/ControllerInfoUtil.d.ts +19 -16
- package/dist/util/ControllerInfoUtil.js +48 -46
- package/dist/util/ControllerMetadataUtil.d.ts +8 -4
- package/dist/util/ControllerMetadataUtil.js +21 -20
- package/dist/util/HTTPInfoUtil.d.ts +19 -15
- package/dist/util/HTTPInfoUtil.js +53 -64
- package/dist/util/HTTPPriorityUtil.d.ts +22 -19
- package/dist/util/HTTPPriorityUtil.js +39 -43
- package/dist/util/MethodInfoUtil.d.ts +22 -19
- package/dist/util/MethodInfoUtil.js +62 -72
- package/dist/util/index.d.ts +8 -6
- package/dist/util/index.js +10 -7
- package/dist/util/validator/ControllerValidator.d.ts +7 -3
- package/dist/util/validator/ControllerValidator.js +15 -14
- package/dist/util/validator/MethodValidator.d.ts +7 -3
- package/dist/util/validator/MethodValidator.js +29 -29
- package/dist/util/validator/index.d.ts +2 -2
- package/dist/util/validator/index.js +4 -3
- package/package.json +31 -35
|
@@ -1,173 +1,159 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { InjectContext } from "../Context.js";
|
|
2
|
+
import { HTTPParamParams, HTTPQueriesParams, HTTPQueryParams } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/http/HTTPParam.d.ts
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
* Inject the request body.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPBody } from 'egg';
|
|
12
|
+
*
|
|
13
|
+
* @HTTPController()
|
|
14
|
+
* export class FooController {
|
|
15
|
+
* @HTTPMethod({
|
|
16
|
+
* path: '/foo',
|
|
17
|
+
* method: HTTPMethodEnum.GET,
|
|
18
|
+
* })
|
|
19
|
+
* // POST /foo -H 'Content-Type: application/json' -d '{"foo": "bar"}'
|
|
20
|
+
* // body = { "foo": "bar" }
|
|
21
|
+
* async bar(@HTTPBody() body: any): Promise<void> {
|
|
22
|
+
* console.log(body);
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function HTTPBody(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
25
28
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
* Inject the request headers.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPHeaders, type IncomingHttpHeaders } from 'egg';
|
|
34
|
+
*
|
|
35
|
+
* @HTTPController()
|
|
36
|
+
* export class FooController {
|
|
37
|
+
* @HTTPMethod({
|
|
38
|
+
* path: '/foo',
|
|
39
|
+
* method: HTTPMethodEnum.GET,
|
|
40
|
+
* })
|
|
41
|
+
* // GET /foo -H 'X-Custom: custom'
|
|
42
|
+
* // headers['x-custom'] = 'custom'
|
|
43
|
+
* async bar(@HTTPHeaders() headers: IncomingHttpHeaders): Promise<void> {
|
|
44
|
+
* console.log(headers);
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function HTTPHeaders(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
47
50
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
* Inject the request query string, the value is string type.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQuery } from 'egg';
|
|
56
|
+
*
|
|
57
|
+
* @HTTPController()
|
|
58
|
+
* export class FooController {
|
|
59
|
+
* @HTTPMethod({
|
|
60
|
+
* path: '/foo',
|
|
61
|
+
* method: HTTPMethodEnum.GET,
|
|
62
|
+
* })
|
|
63
|
+
* // GET /foo?user=asd
|
|
64
|
+
* // user = 'asd'
|
|
65
|
+
* async bar(@HTTPQuery() user?: string): Promise<void> {
|
|
66
|
+
* console.log(user);
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function HTTPQuery(param?: HTTPQueryParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
69
72
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
73
|
+
* Inject the request query strings, all value are Array type.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQueries } from 'egg';
|
|
78
|
+
*
|
|
79
|
+
* @HTTPController()
|
|
80
|
+
* export class FooController {
|
|
81
|
+
* @HTTPMethod({
|
|
82
|
+
* path: '/foo',
|
|
83
|
+
* method: HTTPMethodEnum.GET,
|
|
84
|
+
* })
|
|
85
|
+
* // GET /foo?user=asd&user=fgh
|
|
86
|
+
* // user = ['asd', 'fgh']
|
|
87
|
+
* async bar(@HTTPQueries({ name: 'user' }) users?: string[]): Promise<void> {
|
|
88
|
+
* console.log(users);
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare function HTTPQueries(param?: HTTPQueriesParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
91
94
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
* Inject the request path parameter, the value is string type.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPParam } from 'egg';
|
|
100
|
+
*
|
|
101
|
+
* @HTTPController()
|
|
102
|
+
* export class FooController {
|
|
103
|
+
* @HTTPMethod({
|
|
104
|
+
* path: '/foo/:id',
|
|
105
|
+
* method: HTTPMethodEnum.GET,
|
|
106
|
+
* })
|
|
107
|
+
* // GET /foo/123
|
|
108
|
+
* // id = '123'
|
|
109
|
+
* async bar(@HTTPParam() id: string): Promise<void> {
|
|
110
|
+
* console.log(id);
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function HTTPParam(param?: HTTPParamParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
113
116
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
117
|
+
* Inject the request object.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPRequest } from 'egg';
|
|
122
|
+
*
|
|
123
|
+
* @HTTPController()
|
|
124
|
+
* export class FooController {
|
|
125
|
+
* @HTTPMethod({
|
|
126
|
+
* path: '/foo',
|
|
127
|
+
* method: HTTPMethodEnum.GET,
|
|
128
|
+
* })
|
|
129
|
+
* async bar(@HTTPRequest() request: Request): Promise<void> {
|
|
130
|
+
* console.log(request);
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function HTTPRequest(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
133
136
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* @example
|
|
158
|
-
*
|
|
159
|
-
* ```typescript
|
|
160
|
-
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPContext, type Context } from 'egg';
|
|
161
|
-
*
|
|
162
|
-
* @HTTPController()
|
|
163
|
-
* export class FooController {
|
|
164
|
-
* @HTTPMethod({
|
|
165
|
-
* path: '/foo',
|
|
166
|
-
* method: HTTPMethodEnum.GET,
|
|
167
|
-
* })
|
|
168
|
-
* async bar(@HTTPContext() ctx: Context): Promise<void> {
|
|
169
|
-
* console.log(ctx);
|
|
170
|
-
* }
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
InjectContext as HTTPContext, };
|
|
137
|
+
* Inject the request cookies.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* import { HTTPController, HTTPMethod, HTTPMethodEnum, HTTPCookies, type Cookies } from 'egg';
|
|
142
|
+
*
|
|
143
|
+
* @HTTPController()
|
|
144
|
+
* export class FooController {
|
|
145
|
+
* @HTTPMethod({
|
|
146
|
+
* path: '/foo',
|
|
147
|
+
* method: HTTPMethodEnum.GET,
|
|
148
|
+
* })
|
|
149
|
+
* // GET /foo -H 'Cookie: foo=bar; bar=baz'
|
|
150
|
+
* // cookies = cookies
|
|
151
|
+
* async bar(@HTTPCookies() cookies: Cookies): Promise<void> {
|
|
152
|
+
* console.log(cookies);
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function HTTPCookies(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
158
|
+
//#endregion
|
|
159
|
+
export { HTTPBody, HTTPCookies, HTTPHeaders, HTTPParam, HTTPQueries, HTTPQuery, HTTPRequest };
|