@midwayjs/koa 3.0.13 → 3.1.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/interface.d.ts +1 -1
- package/dist/onerror.js +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +10 -3
- package/package.json +5 -5
package/dist/interface.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ interface BodyParserOptions {
|
|
|
68
68
|
/**
|
|
69
69
|
* requested encoding. Default is utf-8 by co-body
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
encoding?: string;
|
|
72
72
|
/**
|
|
73
73
|
* limit of the urlencoded body. If the body ends up being larger than this limit
|
|
74
74
|
* a 413 error code is returned. Default is 56kb
|
package/dist/onerror.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function detectStatus(err: any): any;
|
|
2
|
-
export declare function accepts(ctx: any): "json" | "
|
|
2
|
+
export declare function accepts(ctx: any): "json" | "html";
|
|
3
3
|
export declare function sendToWormhole(stream: any): Promise<void>;
|
|
4
4
|
export declare function isProduction(app: any): boolean;
|
|
5
5
|
export declare const tpl = "\n<!DOCTYPE html>\n<html>\n <head>\n <title>Error - {{status}}</title>\n <meta name=\"viewport\" content=\"user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0\">\n\n <style>\n body {\n padding: 50px 80px;\n font: 14px \"Helvetica Neue\", Helvetica, sans-serif;\n }\n\n h1 {\n font-size: 2em;\n margin-bottom: 5px;\n }\n\n pre {\n font-size: .8em;\n }\n </style>\n </head>\n <body>\n <div id=\"error\">\n <h1>Error</h1>\n <p>Looks like something broke!</p>\n <p><h2>Stack</h2></p>\n <pre>\n <code>\n{{stack}}\n </code>\n </pre>\n <p><h2>Error Code</h2></p>\n <pre>\n <code>\n{{errorCode}}\n </code>\n </pre>\n </div>\n </body>\n</html>";
|
package/dist/utils.js
CHANGED
|
@@ -12,13 +12,20 @@ function detectStatus(err) {
|
|
|
12
12
|
}
|
|
13
13
|
exports.detectStatus = detectStatus;
|
|
14
14
|
function accepts(ctx) {
|
|
15
|
-
if (ctx
|
|
15
|
+
if (acceptJSON(ctx))
|
|
16
16
|
return 'json';
|
|
17
|
-
if (ctx.acceptJSONP)
|
|
18
|
-
return 'js';
|
|
19
17
|
return 'html';
|
|
20
18
|
}
|
|
21
19
|
exports.accepts = accepts;
|
|
20
|
+
function acceptJSON(ctx) {
|
|
21
|
+
if (ctx.path.endsWith('.json'))
|
|
22
|
+
return true;
|
|
23
|
+
if (ctx.response.type && this.response.type.indexOf('json') >= 0)
|
|
24
|
+
return true;
|
|
25
|
+
if (ctx.accepts('html', 'text', 'json') === 'json')
|
|
26
|
+
return true;
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
22
29
|
function sendToWormhole(stream) {
|
|
23
30
|
return new Promise(resolve => {
|
|
24
31
|
if (typeof stream.resume !== 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@midwayjs/decorator": "^3.0.10",
|
|
27
27
|
"@midwayjs/logger": "^2.15.0",
|
|
28
|
-
"@midwayjs/mock": "^3.0
|
|
28
|
+
"@midwayjs/mock": "^3.1.0",
|
|
29
29
|
"@types/koa": "2.13.4",
|
|
30
30
|
"@types/koa-router": "7.4.4",
|
|
31
31
|
"fs-extra": "10.0.1"
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@koa/router": "^10.0.0",
|
|
35
35
|
"@midwayjs/cookies": "1.0.1",
|
|
36
|
-
"@midwayjs/core": "^3.0
|
|
37
|
-
"@midwayjs/session": "^3.0
|
|
36
|
+
"@midwayjs/core": "^3.1.0",
|
|
37
|
+
"@midwayjs/session": "^3.1.0",
|
|
38
38
|
"koa": "2.13.4",
|
|
39
39
|
"koa-bodyparser": "4.3.0"
|
|
40
40
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=12"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "2074c838e454a9673a044dbe065631dd9f944005"
|
|
50
50
|
}
|