@midwayjs/koa 3.19.2 → 4.0.0-alpha.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.
- package/dist/config/config.default.js +1 -2
- package/dist/configuration.js +2 -2
- package/dist/framework.d.ts +1 -2
- package/dist/framework.js +5 -10
- package/dist/interface.d.ts +1 -0
- package/dist/middleware/bodyparser.middleware.js +2 -2
- package/dist/middleware/fav.middleware.js +2 -2
- package/package.json +7 -7
|
@@ -6,11 +6,10 @@ exports.siteFile = exports.bodyParser = exports.onerror = exports.cookies = expo
|
|
|
6
6
|
*/
|
|
7
7
|
exports.koa = {
|
|
8
8
|
contextLoggerFormat: info => {
|
|
9
|
-
var _a, _b, _c;
|
|
10
9
|
const ctx = info.ctx;
|
|
11
10
|
// format: '[$userId/$ip/$traceId/$use_ms $method $url]'
|
|
12
11
|
const userId = ctx.userId || '-';
|
|
13
|
-
const traceId =
|
|
12
|
+
const traceId = ctx.traceId ?? ctx.tracer?.traceId ?? '-';
|
|
14
13
|
const use = Date.now() - ctx.startTime;
|
|
15
14
|
const label = userId +
|
|
16
15
|
'/' +
|
package/dist/configuration.js
CHANGED
|
@@ -27,6 +27,7 @@ let KoaConfiguration = class KoaConfiguration {
|
|
|
27
27
|
this.koaFramework.useMiddleware([fav_middleware_1.SiteFileMiddleware, bodyparser_middleware_1.BodyParserMiddleware]);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
exports.KoaConfiguration = KoaConfiguration;
|
|
30
31
|
__decorate([
|
|
31
32
|
(0, core_1.Inject)(),
|
|
32
33
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
@@ -45,7 +46,7 @@ __decorate([
|
|
|
45
46
|
__metadata("design:paramtypes", []),
|
|
46
47
|
__metadata("design:returntype", void 0)
|
|
47
48
|
], KoaConfiguration.prototype, "init", null);
|
|
48
|
-
KoaConfiguration = __decorate([
|
|
49
|
+
exports.KoaConfiguration = KoaConfiguration = __decorate([
|
|
49
50
|
(0, core_1.Configuration)({
|
|
50
51
|
namespace: 'koa',
|
|
51
52
|
imports: [session],
|
|
@@ -56,5 +57,4 @@ KoaConfiguration = __decorate([
|
|
|
56
57
|
],
|
|
57
58
|
})
|
|
58
59
|
], KoaConfiguration);
|
|
59
|
-
exports.KoaConfiguration = KoaConfiguration;
|
|
60
60
|
//# sourceMappingURL=configuration.js.map
|
package/dist/framework.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BaseFramework, CommonFilterUnion, CommonMiddlewareUnion, IMidwayBootstrapOptions,
|
|
2
|
+
import { BaseFramework, CommonFilterUnion, CommonMiddlewareUnion, IMidwayBootstrapOptions, RouterInfo } from '@midwayjs/core';
|
|
3
3
|
import { IMidwayKoaApplication, IMidwayKoaConfigurationOptions, IMidwayKoaContext } from './interface';
|
|
4
4
|
import type { DefaultState, Middleware, Next } from 'koa';
|
|
5
5
|
import { Server } from 'http';
|
|
@@ -21,7 +21,6 @@ export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplicat
|
|
|
21
21
|
generateMiddleware(middlewareId: any): Promise<Middleware<DefaultState, IMidwayKoaContext, any>>;
|
|
22
22
|
run(): Promise<void>;
|
|
23
23
|
beforeStop(): Promise<void>;
|
|
24
|
-
getFrameworkType(): MidwayFrameworkType;
|
|
25
24
|
getFrameworkName(): string;
|
|
26
25
|
getServer(): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
27
26
|
getPort(): string;
|
package/dist/framework.js
CHANGED
|
@@ -160,9 +160,8 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
160
160
|
}
|
|
161
161
|
async loadMidwayController() {
|
|
162
162
|
await this.generator.loadMidwayController(newRouter => {
|
|
163
|
-
var _a;
|
|
164
163
|
const dispatchFn = newRouter.middleware();
|
|
165
|
-
dispatchFn._name = `midwayController(${
|
|
164
|
+
dispatchFn._name = `midwayController(${newRouter?.opts?.prefix || '/'})`;
|
|
166
165
|
this.app.use(dispatchFn);
|
|
167
166
|
});
|
|
168
167
|
}
|
|
@@ -181,7 +180,6 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
181
180
|
return mwIns.resolve();
|
|
182
181
|
}
|
|
183
182
|
async run() {
|
|
184
|
-
var _a;
|
|
185
183
|
// load controller
|
|
186
184
|
await this.loadMidwayController();
|
|
187
185
|
// restore use method
|
|
@@ -218,7 +216,7 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
218
216
|
this.server.setTimeout(this.configurationOptions.serverTimeout);
|
|
219
217
|
}
|
|
220
218
|
// set port and listen server
|
|
221
|
-
const customPort =
|
|
219
|
+
const customPort = process.env.MIDWAY_HTTP_PORT ?? this.configurationOptions.port;
|
|
222
220
|
if (customPort) {
|
|
223
221
|
new Promise(resolve => {
|
|
224
222
|
const args = [customPort];
|
|
@@ -240,11 +238,8 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
240
238
|
});
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
|
-
getFrameworkType() {
|
|
244
|
-
return core_1.MidwayFrameworkType.WEB_KOA;
|
|
245
|
-
}
|
|
246
241
|
getFrameworkName() {
|
|
247
|
-
return '
|
|
242
|
+
return 'koa';
|
|
248
243
|
}
|
|
249
244
|
getServer() {
|
|
250
245
|
return this.server;
|
|
@@ -259,8 +254,8 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
259
254
|
this.filterManager.useFilter(Filter);
|
|
260
255
|
}
|
|
261
256
|
};
|
|
262
|
-
MidwayKoaFramework =
|
|
257
|
+
exports.MidwayKoaFramework = MidwayKoaFramework;
|
|
258
|
+
exports.MidwayKoaFramework = MidwayKoaFramework = __decorate([
|
|
263
259
|
(0, core_1.Framework)()
|
|
264
260
|
], MidwayKoaFramework);
|
|
265
|
-
exports.MidwayKoaFramework = MidwayKoaFramework;
|
|
266
261
|
//# sourceMappingURL=framework.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -23,12 +23,12 @@ let BodyParserMiddleware = class BodyParserMiddleware {
|
|
|
23
23
|
return 'bodyParser';
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
exports.BodyParserMiddleware = BodyParserMiddleware;
|
|
26
27
|
__decorate([
|
|
27
28
|
(0, core_1.Config)('bodyParser'),
|
|
28
29
|
__metadata("design:type", Object)
|
|
29
30
|
], BodyParserMiddleware.prototype, "bodyparserConfig", void 0);
|
|
30
|
-
BodyParserMiddleware = __decorate([
|
|
31
|
+
exports.BodyParserMiddleware = BodyParserMiddleware = __decorate([
|
|
31
32
|
(0, core_1.Middleware)()
|
|
32
33
|
], BodyParserMiddleware);
|
|
33
|
-
exports.BodyParserMiddleware = BodyParserMiddleware;
|
|
34
34
|
//# sourceMappingURL=bodyparser.middleware.js.map
|
|
@@ -51,12 +51,12 @@ let SiteFileMiddleware = class SiteFileMiddleware {
|
|
|
51
51
|
return 'siteFile';
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
exports.SiteFileMiddleware = SiteFileMiddleware;
|
|
54
55
|
__decorate([
|
|
55
56
|
(0, core_1.Config)('siteFile'),
|
|
56
57
|
__metadata("design:type", Object)
|
|
57
58
|
], SiteFileMiddleware.prototype, "siteFileConfig", void 0);
|
|
58
|
-
SiteFileMiddleware = __decorate([
|
|
59
|
+
exports.SiteFileMiddleware = SiteFileMiddleware = __decorate([
|
|
59
60
|
(0, core_1.Middleware)()
|
|
60
61
|
], SiteFileMiddleware);
|
|
61
|
-
exports.SiteFileMiddleware = SiteFileMiddleware;
|
|
62
62
|
//# sourceMappingURL=fav.middleware.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "node
|
|
10
|
-
"cov": "node
|
|
9
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
10
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
|
|
11
11
|
"ci": "npm run test"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/
|
|
27
|
+
"@midwayjs/core": "^4.0.0-alpha.1",
|
|
28
|
+
"@midwayjs/mock": "^4.0.0-alpha.1",
|
|
28
29
|
"@types/koa-router": "7.4.8",
|
|
29
30
|
"fs-extra": "11.2.0"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@koa/router": "^12.0.0",
|
|
33
34
|
"@midwayjs/cookies": "^1.0.2",
|
|
34
|
-
"@midwayjs/
|
|
35
|
-
"@midwayjs/session": "^3.19.2",
|
|
35
|
+
"@midwayjs/session": "^4.0.0-alpha.1",
|
|
36
36
|
"@types/koa": "2.15.0",
|
|
37
37
|
"@types/qs": "6.9.17",
|
|
38
38
|
"koa": "2.15.3",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=12"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
51
51
|
}
|