@midwayjs/koa 4.0.0-beta.7 → 4.0.0-beta.9
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/configuration.js +3 -0
- package/dist/framework.d.ts +0 -1
- package/dist/framework.js +12 -1
- package/dist/interface.d.ts +0 -3
- package/dist/middleware/bodyparser.middleware.js +1 -0
- package/dist/middleware/fav.middleware.js +1 -0
- package/dist/onerror.js +1 -2
- package/dist/utils.js +7 -7
- package/package.json +8 -8
package/dist/configuration.js
CHANGED
|
@@ -17,6 +17,9 @@ const DefaultConfig = require("./config/config.default");
|
|
|
17
17
|
const bodyparser_middleware_1 = require("./middleware/bodyparser.middleware");
|
|
18
18
|
const fav_middleware_1 = require("./middleware/fav.middleware");
|
|
19
19
|
let KoaConfiguration = class KoaConfiguration {
|
|
20
|
+
decoratorService;
|
|
21
|
+
koaFramework;
|
|
22
|
+
configService;
|
|
20
23
|
init() {
|
|
21
24
|
// register param decorator
|
|
22
25
|
this.decoratorService.registerParameterHandler(core_1.WEB_ROUTER_PARAM_KEY, options => {
|
package/dist/framework.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { BaseFramework, CommonFilterUnion, CommonMiddlewareUnion, IMidwayBootstrapOptions, RouterInfo } from '@midwayjs/core';
|
|
3
2
|
import { IMidwayKoaApplication, IMidwayKoaConfigurationOptions, IMidwayKoaContext } from './interface';
|
|
4
3
|
import type { DefaultState, Middleware, Next } from 'koa';
|
package/dist/framework.js
CHANGED
|
@@ -17,6 +17,8 @@ const querystring = require("querystring");
|
|
|
17
17
|
const utils_1 = require("./utils");
|
|
18
18
|
const COOKIES = Symbol('context#cookies');
|
|
19
19
|
class KoaControllerGenerator extends core_1.WebControllerGenerator {
|
|
20
|
+
app;
|
|
21
|
+
webRouterService;
|
|
20
22
|
constructor(app, webRouterService) {
|
|
21
23
|
super(app, webRouterService);
|
|
22
24
|
this.app = app;
|
|
@@ -32,6 +34,9 @@ class KoaControllerGenerator extends core_1.WebControllerGenerator {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
37
|
+
server;
|
|
38
|
+
generator;
|
|
39
|
+
webRouterService;
|
|
35
40
|
configure() {
|
|
36
41
|
return this.configService.getConfiguration('koa');
|
|
37
42
|
}
|
|
@@ -110,7 +115,13 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
110
115
|
return c[str];
|
|
111
116
|
if (self.configurationOptions.queryParseMode) {
|
|
112
117
|
// use qs module to parse query
|
|
113
|
-
|
|
118
|
+
const parseOptions = {
|
|
119
|
+
...self.configurationOptions.queryParseOptions,
|
|
120
|
+
...(self.configurationOptions.queryParseMode === 'first'
|
|
121
|
+
? { duplicates: 'first' }
|
|
122
|
+
: {}),
|
|
123
|
+
};
|
|
124
|
+
c[str] = qs.parse(str, parseOptions);
|
|
114
125
|
}
|
|
115
126
|
else {
|
|
116
127
|
// use querystring to parse query by default
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { IConfigurationOptions, IMidwayApplication, IMidwayContext } from '@midwayjs/core';
|
|
5
2
|
import * as koa from 'koa';
|
|
6
3
|
import { Context as KoaContext, DefaultState, Middleware, Next } from 'koa';
|
|
@@ -13,6 +13,7 @@ exports.BodyParserMiddleware = void 0;
|
|
|
13
13
|
const koaBodyParser = require("koa-bodyparser");
|
|
14
14
|
const core_1 = require("@midwayjs/core");
|
|
15
15
|
let BodyParserMiddleware = class BodyParserMiddleware {
|
|
16
|
+
bodyparserConfig;
|
|
16
17
|
resolve() {
|
|
17
18
|
// use bodyparser middleware
|
|
18
19
|
if (this.bodyparserConfig.enable) {
|
|
@@ -14,6 +14,7 @@ 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 {
|
|
17
|
+
siteFileConfig;
|
|
17
18
|
resolve() {
|
|
18
19
|
// use bodyparser middleware
|
|
19
20
|
if (this.siteFileConfig.enable) {
|
package/dist/onerror.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupOnError =
|
|
3
|
+
exports.setupOnError = setupOnError;
|
|
4
4
|
const http = require("http");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
const core_1 = require("@midwayjs/core");
|
|
@@ -182,5 +182,4 @@ function setupOnError(app, config, logger) {
|
|
|
182
182
|
this.res.end(this.body);
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
exports.setupOnError = setupOnError;
|
|
186
185
|
//# sourceMappingURL=onerror.js.map
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.tpl = void 0;
|
|
4
|
+
exports.detectStatus = detectStatus;
|
|
5
|
+
exports.accepts = accepts;
|
|
6
|
+
exports.sendToWormhole = sendToWormhole;
|
|
7
|
+
exports.isProduction = isProduction;
|
|
8
|
+
exports.escapeHtml = escapeHtml;
|
|
9
|
+
exports.getFreePort = getFreePort;
|
|
4
10
|
const net_1 = require("net");
|
|
5
11
|
function detectStatus(err) {
|
|
6
12
|
// detect status
|
|
@@ -11,13 +17,11 @@ function detectStatus(err) {
|
|
|
11
17
|
}
|
|
12
18
|
return status;
|
|
13
19
|
}
|
|
14
|
-
exports.detectStatus = detectStatus;
|
|
15
20
|
function accepts(ctx) {
|
|
16
21
|
if (acceptJSON(ctx))
|
|
17
22
|
return 'json';
|
|
18
23
|
return 'html';
|
|
19
24
|
}
|
|
20
|
-
exports.accepts = accepts;
|
|
21
25
|
function acceptJSON(ctx) {
|
|
22
26
|
if (ctx.path.endsWith('.json'))
|
|
23
27
|
return true;
|
|
@@ -60,11 +64,9 @@ function sendToWormhole(stream) {
|
|
|
60
64
|
stream.on('error', onError);
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
|
-
exports.sendToWormhole = sendToWormhole;
|
|
64
67
|
function isProduction(app) {
|
|
65
68
|
return app.getEnv() !== 'local' && app.getEnv() !== 'unittest';
|
|
66
69
|
}
|
|
67
|
-
exports.isProduction = isProduction;
|
|
68
70
|
exports.tpl = `
|
|
69
71
|
<!DOCTYPE html>
|
|
70
72
|
<html>
|
|
@@ -153,7 +155,6 @@ function escapeHtml(string) {
|
|
|
153
155
|
}
|
|
154
156
|
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
155
157
|
}
|
|
156
|
-
exports.escapeHtml = escapeHtml;
|
|
157
158
|
async function getFreePort() {
|
|
158
159
|
return new Promise((resolve, reject) => {
|
|
159
160
|
const server = (0, net_1.createServer)();
|
|
@@ -169,5 +170,4 @@ async function getFreePort() {
|
|
|
169
170
|
});
|
|
170
171
|
});
|
|
171
172
|
}
|
|
172
|
-
exports.getFreePort = getFreePort;
|
|
173
173
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.9",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/core": "^4.0.0-beta.
|
|
28
|
-
"@midwayjs/mock": "^4.0.0-beta.
|
|
29
|
-
"@types/koa-router": "7.4.
|
|
27
|
+
"@midwayjs/core": "^4.0.0-beta.9",
|
|
28
|
+
"@midwayjs/mock": "^4.0.0-beta.9",
|
|
29
|
+
"@types/koa-router": "7.4.9",
|
|
30
30
|
"axios": "1.12.0",
|
|
31
|
-
"fs-extra": "11.3.
|
|
31
|
+
"fs-extra": "11.3.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@koa/router": "^12.0.0",
|
|
35
35
|
"@midwayjs/cookies": "^1.3.0",
|
|
36
|
-
"@midwayjs/session": "^4.0.0-beta.
|
|
36
|
+
"@midwayjs/session": "^4.0.0-beta.9",
|
|
37
37
|
"@types/koa": "3.0.0",
|
|
38
38
|
"@types/qs": "6.9.18",
|
|
39
39
|
"koa": "3.0.3",
|
|
40
40
|
"koa-bodyparser": "4.4.1",
|
|
41
|
-
"qs": "6.14.
|
|
41
|
+
"qs": "6.14.1"
|
|
42
42
|
},
|
|
43
43
|
"author": "Harry Chen <czy88840616@gmail.com>",
|
|
44
44
|
"repository": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=20"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "771e83974ef9f3d78c296e4ee0c8c68db44f6b31"
|
|
52
52
|
}
|