@midwayjs/core 3.5.3 → 3.5.4-beta.1
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.
|
@@ -122,10 +122,12 @@ export declare class MidwayWebRouterService {
|
|
|
122
122
|
* @param controllerOption
|
|
123
123
|
* @param functionMeta
|
|
124
124
|
*/
|
|
125
|
-
addController(controllerClz: any, controllerOption: ControllerOption, functionMeta?: boolean):
|
|
125
|
+
addController(controllerClz: any, controllerOption: ControllerOption, functionMeta?: boolean): any;
|
|
126
|
+
addController(controllerClz: any, controllerOption: ControllerOption, resourceOptions?: {
|
|
127
|
+
resourceFilter: (routerInfo: RouterInfo) => boolean;
|
|
128
|
+
}, functionMeta?: boolean): any;
|
|
126
129
|
/**
|
|
127
130
|
* dynamically add a route to root prefix
|
|
128
|
-
* @param routerPath
|
|
129
131
|
* @param routerFunction
|
|
130
132
|
* @param routerInfoOption
|
|
131
133
|
*/
|
|
@@ -57,14 +57,15 @@ let MidwayWebRouterService = class MidwayWebRouterService {
|
|
|
57
57
|
return routeB.prefix.length - routeA.prefix.length;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
* dynamically add a controller
|
|
62
|
-
* @param controllerClz
|
|
63
|
-
* @param controllerOption
|
|
64
|
-
* @param functionMeta
|
|
65
|
-
*/
|
|
66
|
-
addController(controllerClz, controllerOption, functionMeta = false) {
|
|
60
|
+
addController(controllerClz, controllerOption, resourceOptions = {}, functionMeta = false) {
|
|
67
61
|
var _a;
|
|
62
|
+
if (resourceOptions && typeof resourceOptions === 'boolean') {
|
|
63
|
+
functionMeta = resourceOptions;
|
|
64
|
+
resourceOptions = undefined;
|
|
65
|
+
}
|
|
66
|
+
if (!resourceOptions) {
|
|
67
|
+
resourceOptions = {};
|
|
68
|
+
}
|
|
68
69
|
const controllerId = (0, decorator_1.getProviderName)(controllerClz);
|
|
69
70
|
debug(`[core]: Found Controller ${controllerId}.`);
|
|
70
71
|
const id = (0, decorator_1.getProviderUUId)(controllerClz);
|
|
@@ -117,6 +118,10 @@ let MidwayWebRouterService = class MidwayWebRouterService {
|
|
|
117
118
|
const webRouterInfo = (0, decorator_1.getClassMetadata)(decorator_1.WEB_ROUTER_KEY, controllerClz);
|
|
118
119
|
if (webRouterInfo && typeof webRouterInfo[Symbol.iterator] === 'function') {
|
|
119
120
|
for (const webRouter of webRouterInfo) {
|
|
121
|
+
if (resourceOptions.resourceFilter &&
|
|
122
|
+
!resourceOptions.resourceFilter(webRouter)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
120
125
|
const routeArgsInfo = (0, decorator_1.getPropertyDataFromClass)(decorator_1.WEB_ROUTER_PARAM_KEY, controllerClz, webRouter.method) || [];
|
|
121
126
|
const routerResponseData = (0, decorator_1.getPropertyMetadata)(decorator_1.WEB_RESPONSE_KEY, controllerClz, webRouter.method) || [];
|
|
122
127
|
const data = {
|
|
@@ -154,7 +159,6 @@ let MidwayWebRouterService = class MidwayWebRouterService {
|
|
|
154
159
|
}
|
|
155
160
|
/**
|
|
156
161
|
* dynamically add a route to root prefix
|
|
157
|
-
* @param routerPath
|
|
158
162
|
* @param routerFunction
|
|
159
163
|
* @param routerInfoOption
|
|
160
164
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4-beta.1",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=12"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a603d2348d6141f8f723901498f03a162a037708"
|
|
50
50
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|