@midwayjs/koa 3.5.3 → 3.7.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/config/config.default.d.ts +1 -0
- package/dist/config/config.default.js +1 -0
- package/dist/configuration.js +8 -8
- package/dist/framework.d.ts +2 -2
- package/dist/framework.js +5 -2
- package/dist/interface.d.ts +9 -1
- package/dist/middleware/bodyparser.middleware.js +3 -3
- package/dist/middleware/fav.middleware.js +3 -3
- package/dist/onerror.js +2 -2
- package/package.json +5 -6
package/dist/configuration.js
CHANGED
|
@@ -10,7 +10,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.KoaConfiguration = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
13
|
const core_1 = require("@midwayjs/core");
|
|
15
14
|
const session = require("@midwayjs/session");
|
|
16
15
|
const framework_1 = require("./framework");
|
|
@@ -20,8 +19,9 @@ const fav_middleware_1 = require("./middleware/fav.middleware");
|
|
|
20
19
|
let KoaConfiguration = class KoaConfiguration {
|
|
21
20
|
init() {
|
|
22
21
|
// register param decorator
|
|
23
|
-
this.decoratorService.registerParameterHandler(
|
|
24
|
-
|
|
22
|
+
this.decoratorService.registerParameterHandler(core_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
23
|
+
var _a;
|
|
24
|
+
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType, (_a = options.metadata) === null || _a === void 0 ? void 0 : _a.pipes)(options.originArgs[0], options.originArgs[1]);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
async onReady() {
|
|
@@ -29,25 +29,25 @@ let KoaConfiguration = class KoaConfiguration {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
__decorate([
|
|
32
|
-
(0,
|
|
32
|
+
(0, core_1.Inject)(),
|
|
33
33
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
34
34
|
], KoaConfiguration.prototype, "decoratorService", void 0);
|
|
35
35
|
__decorate([
|
|
36
|
-
(0,
|
|
36
|
+
(0, core_1.Inject)(),
|
|
37
37
|
__metadata("design:type", framework_1.MidwayKoaFramework)
|
|
38
38
|
], KoaConfiguration.prototype, "koaFramework", void 0);
|
|
39
39
|
__decorate([
|
|
40
|
-
(0,
|
|
40
|
+
(0, core_1.Inject)(),
|
|
41
41
|
__metadata("design:type", core_1.MidwayConfigService)
|
|
42
42
|
], KoaConfiguration.prototype, "configService", void 0);
|
|
43
43
|
__decorate([
|
|
44
|
-
(0,
|
|
44
|
+
(0, core_1.Init)(),
|
|
45
45
|
__metadata("design:type", Function),
|
|
46
46
|
__metadata("design:paramtypes", []),
|
|
47
47
|
__metadata("design:returntype", void 0)
|
|
48
48
|
], KoaConfiguration.prototype, "init", null);
|
|
49
49
|
KoaConfiguration = __decorate([
|
|
50
|
-
(0,
|
|
50
|
+
(0, core_1.Configuration)({
|
|
51
51
|
namespace: 'koa',
|
|
52
52
|
imports: [session],
|
|
53
53
|
importConfigs: [
|
package/dist/framework.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { BaseFramework, CommonFilterUnion, CommonMiddlewareUnion, IMidwayBootstrapOptions, MidwayFrameworkType, RouterInfo } from '@midwayjs/core';
|
|
3
3
|
import { IMidwayKoaApplication, IMidwayKoaConfigurationOptions, IMidwayKoaContext } from './interface';
|
|
4
4
|
import type { DefaultState, Middleware, Next } from 'koa';
|
|
5
|
-
import { Server } from '
|
|
5
|
+
import { Server } from 'http';
|
|
6
6
|
export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplication, IMidwayKoaContext, IMidwayKoaConfigurationOptions, Next> {
|
|
7
7
|
private server;
|
|
8
8
|
private generator;
|
|
@@ -23,7 +23,7 @@ export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplicat
|
|
|
23
23
|
beforeStop(): Promise<void>;
|
|
24
24
|
getFrameworkType(): MidwayFrameworkType;
|
|
25
25
|
getFrameworkName(): string;
|
|
26
|
-
getServer(): Server
|
|
26
|
+
getServer(): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
27
27
|
getPort(): string;
|
|
28
28
|
useMiddleware(Middleware: CommonMiddlewareUnion<IMidwayKoaContext, Next, unknown>): void;
|
|
29
29
|
useFilter(Filter: CommonFilterUnion<IMidwayKoaContext, Next, unknown>): void;
|
package/dist/framework.js
CHANGED
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.MidwayKoaFramework = void 0;
|
|
10
10
|
const core_1 = require("@midwayjs/core");
|
|
11
11
|
const cookies_1 = require("@midwayjs/cookies");
|
|
12
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
13
12
|
const Router = require("@koa/router");
|
|
14
13
|
const koa = require("koa");
|
|
15
14
|
const onerror_1 = require("./onerror");
|
|
@@ -146,6 +145,10 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
146
145
|
}
|
|
147
146
|
// register httpServer to applicationContext
|
|
148
147
|
this.applicationContext.registerObject(core_1.HTTP_SERVER_KEY, this.server);
|
|
148
|
+
// server timeout
|
|
149
|
+
if (core_1.Types.isNumber(this.configurationOptions.serverTimeout)) {
|
|
150
|
+
this.server.setTimeout(this.configurationOptions.serverTimeout);
|
|
151
|
+
}
|
|
149
152
|
// set port and listen server
|
|
150
153
|
const customPort = (_a = process.env.MIDWAY_HTTP_PORT) !== null && _a !== void 0 ? _a : this.configurationOptions.port;
|
|
151
154
|
if (customPort) {
|
|
@@ -189,7 +192,7 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
189
192
|
}
|
|
190
193
|
};
|
|
191
194
|
MidwayKoaFramework = __decorate([
|
|
192
|
-
(0,
|
|
195
|
+
(0, core_1.Framework)()
|
|
193
196
|
], MidwayKoaFramework);
|
|
194
197
|
exports.MidwayKoaFramework = MidwayKoaFramework;
|
|
195
198
|
//# sourceMappingURL=framework.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { IConfigurationOptions, IMidwayApplication, IMidwayContext } from '@midwayjs/core';
|
|
3
3
|
import * as koa from 'koa';
|
|
4
4
|
import { Context as KoaContext, DefaultState, Middleware, Next } from 'koa';
|
|
5
|
-
import { RouterParamValue } from '@midwayjs/
|
|
5
|
+
import { RouterParamValue } from '@midwayjs/core';
|
|
6
6
|
export declare type IMidwayKoaContext = IMidwayContext<KoaContext>;
|
|
7
7
|
export declare type IMidwayKoaApplication = IMidwayApplication<IMidwayKoaContext, koa<DefaultState, IMidwayKoaContext> & {
|
|
8
8
|
generateController(controllerMapping: string, routeArgsInfo?: RouterParamValue[], routerResponseData?: any[]): Middleware<DefaultState, IMidwayKoaContext>;
|
|
@@ -66,6 +66,14 @@ export interface IMidwayKoaConfigurationOptions extends IConfigurationOptions {
|
|
|
66
66
|
* Max IPs read from proxy IP header, default to 0 (means infinity)
|
|
67
67
|
*/
|
|
68
68
|
maxIpsCount?: number;
|
|
69
|
+
/**
|
|
70
|
+
* server timeout in milliseconds, default to 2 minutes.
|
|
71
|
+
*
|
|
72
|
+
* for special request, just use `ctx.req.setTimeout(ms)`
|
|
73
|
+
*
|
|
74
|
+
* @see https://nodejs.org/api/http.html#http_server_timeout
|
|
75
|
+
*/
|
|
76
|
+
serverTimeout?: number;
|
|
69
77
|
}
|
|
70
78
|
export declare type MiddlewareParamArray = Array<Middleware<DefaultState, IMidwayKoaContext>>;
|
|
71
79
|
export interface IWebMiddleware {
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BodyParserMiddleware = void 0;
|
|
13
13
|
const koaBodyParser = require("koa-bodyparser");
|
|
14
|
-
const
|
|
14
|
+
const core_1 = require("@midwayjs/core");
|
|
15
15
|
let BodyParserMiddleware = class BodyParserMiddleware {
|
|
16
16
|
resolve() {
|
|
17
17
|
// use bodyparser middleware
|
|
@@ -24,11 +24,11 @@ let BodyParserMiddleware = class BodyParserMiddleware {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
__decorate([
|
|
27
|
-
(0,
|
|
27
|
+
(0, core_1.Config)('bodyParser'),
|
|
28
28
|
__metadata("design:type", Object)
|
|
29
29
|
], BodyParserMiddleware.prototype, "bodyparserConfig", void 0);
|
|
30
30
|
BodyParserMiddleware = __decorate([
|
|
31
|
-
(0,
|
|
31
|
+
(0, core_1.Middleware)()
|
|
32
32
|
], BodyParserMiddleware);
|
|
33
33
|
exports.BodyParserMiddleware = BodyParserMiddleware;
|
|
34
34
|
//# sourceMappingURL=bodyparser.middleware.js.map
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SiteFileMiddleware = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const path = require('path');
|
|
15
15
|
const MAX_AGE = 'public, max-age=2592000'; // 30 days
|
|
16
16
|
let SiteFileMiddleware = class SiteFileMiddleware {
|
|
@@ -52,11 +52,11 @@ let SiteFileMiddleware = class SiteFileMiddleware {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
__decorate([
|
|
55
|
-
(0,
|
|
55
|
+
(0, core_1.Config)('siteFile'),
|
|
56
56
|
__metadata("design:type", Object)
|
|
57
57
|
], SiteFileMiddleware.prototype, "siteFileConfig", void 0);
|
|
58
58
|
SiteFileMiddleware = __decorate([
|
|
59
|
-
(0,
|
|
59
|
+
(0, core_1.Middleware)()
|
|
60
60
|
], SiteFileMiddleware);
|
|
61
61
|
exports.SiteFileMiddleware = SiteFileMiddleware;
|
|
62
62
|
//# sourceMappingURL=fav.middleware.js.map
|
package/dist/onerror.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupOnError = void 0;
|
|
4
4
|
const http = require("http");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@midwayjs/core");
|
|
7
7
|
function setupOnError(app, config, logger) {
|
|
8
8
|
const errorOptions = Object.assign({
|
|
9
9
|
// support customize accepts function
|
|
@@ -117,7 +117,7 @@ function setupOnError(app, config, logger) {
|
|
|
117
117
|
let errMsg = err;
|
|
118
118
|
if (typeof err === 'object') {
|
|
119
119
|
try {
|
|
120
|
-
errMsg =
|
|
120
|
+
errMsg = core_1.Utils.safeStringify(err);
|
|
121
121
|
// eslint-disable-next-line no-empty
|
|
122
122
|
}
|
|
123
123
|
catch (e) { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -24,9 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/decorator": "^3.4.11",
|
|
28
27
|
"@midwayjs/logger": "^2.15.0",
|
|
29
|
-
"@midwayjs/mock": "^3.
|
|
28
|
+
"@midwayjs/mock": "^3.7.0",
|
|
30
29
|
"@types/koa": "2.13.5",
|
|
31
30
|
"@types/koa-router": "7.4.4",
|
|
32
31
|
"fs-extra": "10.0.1"
|
|
@@ -34,8 +33,8 @@
|
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@koa/router": "^11.0.0",
|
|
36
35
|
"@midwayjs/cookies": "^1.0.2",
|
|
37
|
-
"@midwayjs/core": "^3.
|
|
38
|
-
"@midwayjs/session": "^3.
|
|
36
|
+
"@midwayjs/core": "^3.7.0",
|
|
37
|
+
"@midwayjs/session": "^3.7.0",
|
|
39
38
|
"koa": "2.13.4",
|
|
40
39
|
"koa-bodyparser": "4.3.0"
|
|
41
40
|
},
|
|
@@ -47,5 +46,5 @@
|
|
|
47
46
|
"engines": {
|
|
48
47
|
"node": ">=12"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "99386083ee26b386fd508b9c892091c914e77535"
|
|
51
50
|
}
|