@midwayjs/koa 3.11.12 → 3.12.0
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/framework.js +22 -0
- package/index.d.ts +1 -0
- package/package.json +6 -6
package/dist/framework.js
CHANGED
|
@@ -63,6 +63,28 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
63
63
|
this.state = value;
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(this.app.context, 'forward', {
|
|
67
|
+
get() {
|
|
68
|
+
return async function (url) {
|
|
69
|
+
const routerService = this.requestContext.get(core_1.MidwayWebRouterService);
|
|
70
|
+
const matchedUrlRouteInfo = await routerService.getMatchedRouterInfo(url, this.method);
|
|
71
|
+
if (matchedUrlRouteInfo) {
|
|
72
|
+
if (matchedUrlRouteInfo.controllerClz) {
|
|
73
|
+
// normal class controller router
|
|
74
|
+
const controllerInstance = await this.requestContext.getAsync(matchedUrlRouteInfo.controllerClz);
|
|
75
|
+
return controllerInstance[matchedUrlRouteInfo.method](this);
|
|
76
|
+
}
|
|
77
|
+
else if (typeof matchedUrlRouteInfo.method === 'function') {
|
|
78
|
+
// dynamic router
|
|
79
|
+
return matchedUrlRouteInfo.method(this);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new core_1.httpError.NotFoundError(`Forward url ${url} Not Found`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
});
|
|
66
88
|
const onerrorConfig = this.configService.getConfiguration('onerror');
|
|
67
89
|
(0, onerror_1.setupOnError)(this.app, onerrorConfig, this.logger);
|
|
68
90
|
// not found middleware
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@midwayjs/logger": "^2.15.0",
|
|
28
|
-
"@midwayjs/mock": "^3.
|
|
28
|
+
"@midwayjs/mock": "^3.12.0",
|
|
29
29
|
"@types/koa": "2.13.6",
|
|
30
30
|
"@types/koa-router": "7.4.4",
|
|
31
31
|
"fs-extra": "11.1.1"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@koa/router": "^11.0.0",
|
|
35
35
|
"@midwayjs/cookies": "^1.0.2",
|
|
36
|
-
"@midwayjs/core": "^3.
|
|
37
|
-
"@midwayjs/session": "^3.
|
|
36
|
+
"@midwayjs/core": "^3.12.0",
|
|
37
|
+
"@midwayjs/session": "^3.12.0",
|
|
38
38
|
"koa": "2.14.1",
|
|
39
|
-
"koa-bodyparser": "4.4.
|
|
39
|
+
"koa-bodyparser": "4.4.1"
|
|
40
40
|
},
|
|
41
41
|
"author": "Harry Chen <czy88840616@gmail.com>",
|
|
42
42
|
"repository": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=12"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0e9a08cd078c4c4dedfa753a8c1025806cc0b0a2"
|
|
50
50
|
}
|