@midwayjs/core 3.4.0-beta.4 → 3.4.0-beta.5
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.
|
@@ -115,7 +115,7 @@ class WebControllerGenerator {
|
|
|
115
115
|
debug(`[core]: Load Router "${routeInfo.requestMethod.toUpperCase()} ${routeInfo.url}"`);
|
|
116
116
|
// apply controller from request context
|
|
117
117
|
// eslint-disable-next-line prefer-spread
|
|
118
|
-
newRouter[routeInfo.requestMethod].apply(newRouter, routerArgs);
|
|
118
|
+
newRouter[routeInfo.requestMethod.toLowerCase()].apply(newRouter, routerArgs);
|
|
119
119
|
}
|
|
120
120
|
routerHandler && routerHandler(newRouter);
|
|
121
121
|
}
|
|
@@ -137,7 +137,7 @@ let MidwayServerlessFunctionService = class MidwayServerlessFunctionService exte
|
|
|
137
137
|
}
|
|
138
138
|
addServerlessFunction(func, triggerOptions, functionOptions = {}) {
|
|
139
139
|
var _a, _b;
|
|
140
|
-
const prefix = '
|
|
140
|
+
const prefix = '';
|
|
141
141
|
if (!this.routes.has(prefix)) {
|
|
142
142
|
this.routes.set(prefix, []);
|
|
143
143
|
this.routesPriority.push({
|
|
@@ -146,7 +146,7 @@ let MidwayServerlessFunctionService = class MidwayServerlessFunctionService exte
|
|
|
146
146
|
middleware: [],
|
|
147
147
|
routerOptions: {},
|
|
148
148
|
controllerId: undefined,
|
|
149
|
-
routerModule:
|
|
149
|
+
routerModule: undefined,
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
const functionName = (_a = triggerOptions.functionName) !== null && _a !== void 0 ? _a : functionOptions.functionName;
|
|
@@ -74,7 +74,7 @@ export interface RouterInfo {
|
|
|
74
74
|
*/
|
|
75
75
|
functionMetadata?: any;
|
|
76
76
|
}
|
|
77
|
-
export declare type DynamicRouterInfo = Omit<RouterInfo, 'id' | '
|
|
77
|
+
export declare type DynamicRouterInfo = Omit<RouterInfo, 'id' | 'method' | 'controllerId' | 'controllerMiddleware' | 'responseMetadata'>;
|
|
78
78
|
export interface RouterPriority {
|
|
79
79
|
prefix: string;
|
|
80
80
|
priority: number;
|
|
@@ -112,7 +112,7 @@ export declare class MidwayWebRouterService {
|
|
|
112
112
|
* @param routerFunction
|
|
113
113
|
* @param routerInfoOption
|
|
114
114
|
*/
|
|
115
|
-
addRouter(
|
|
115
|
+
addRouter(routerFunction: (...args: any[]) => void, routerInfoOption: DynamicRouterInfo): void;
|
|
116
116
|
sortRouter(urlMatchList: RouterInfo[]): {
|
|
117
117
|
_pureRouter: string;
|
|
118
118
|
_level: number;
|
|
@@ -156,10 +156,21 @@ let MidwayWebRouterService = class MidwayWebRouterService {
|
|
|
156
156
|
* @param routerFunction
|
|
157
157
|
* @param routerInfoOption
|
|
158
158
|
*/
|
|
159
|
-
addRouter(
|
|
160
|
-
|
|
159
|
+
addRouter(routerFunction, routerInfoOption) {
|
|
160
|
+
const prefix = routerInfoOption.prefix || '';
|
|
161
|
+
if (!this.routes.has(prefix)) {
|
|
162
|
+
this.routes.set(prefix, []);
|
|
163
|
+
this.routesPriority.push({
|
|
164
|
+
prefix,
|
|
165
|
+
priority: -999,
|
|
166
|
+
middleware: [],
|
|
167
|
+
routerOptions: {},
|
|
168
|
+
controllerId: undefined,
|
|
169
|
+
routerModule: undefined,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
this.checkDuplicateAndPush(prefix, Object.assign(routerInfoOption, {
|
|
161
173
|
method: routerFunction,
|
|
162
|
-
url: routerPath,
|
|
163
174
|
}));
|
|
164
175
|
}
|
|
165
176
|
sortRouter(urlMatchList) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.4.0-beta.
|
|
3
|
+
"version": "3.4.0-beta.5",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^3.4.0-beta.
|
|
24
|
+
"@midwayjs/decorator": "^3.4.0-beta.5",
|
|
25
25
|
"koa": "2.13.4",
|
|
26
26
|
"midway-test-component": "*",
|
|
27
27
|
"mm": "3.2.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d84d1c77aed1fd973d002ab65cd0adeadb7924a6"
|
|
49
49
|
}
|