@midwayjs/koa 3.0.0-beta.16 → 3.0.0-beta.17
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.d.ts +1 -0
- package/dist/framework.js +3 -0
- package/dist/interface.d.ts +55 -3
- package/package.json +8 -9
package/dist/framework.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplicat
|
|
|
23
23
|
getFrameworkType(): MidwayFrameworkType;
|
|
24
24
|
getFrameworkName(): string;
|
|
25
25
|
getServer(): Server;
|
|
26
|
+
getPort(): string;
|
|
26
27
|
useMiddleware(Middleware: CommonMiddlewareUnion<IMidwayKoaContext, Next, unknown>): void;
|
|
27
28
|
useFilter(Filter: CommonFilterUnion<IMidwayKoaContext, Next, unknown>): void;
|
|
28
29
|
}
|
package/dist/framework.js
CHANGED
|
@@ -174,6 +174,9 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
|
|
|
174
174
|
getServer() {
|
|
175
175
|
return this.server;
|
|
176
176
|
}
|
|
177
|
+
getPort() {
|
|
178
|
+
return process.env.MIDWAY_HTTP_PORT;
|
|
179
|
+
}
|
|
177
180
|
useMiddleware(Middleware) {
|
|
178
181
|
this.middlewareManager.insertLast(Middleware);
|
|
179
182
|
}
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/// <reference types="koa-session" />
|
|
2
1
|
/// <reference types="node" />
|
|
3
2
|
import { IConfigurationOptions, IMidwayApplication, IMidwayContext } from '@midwayjs/core';
|
|
4
3
|
import * as koa from 'koa';
|
|
5
4
|
import { Context as KoaContext, DefaultState, Middleware, Next } from 'koa';
|
|
6
5
|
import { RouterParamValue } from '@midwayjs/decorator';
|
|
7
|
-
import * as bodyParser from 'koa-bodyparser';
|
|
8
6
|
import { CookieSetOptions } from '@midwayjs/cookies';
|
|
9
7
|
export declare type IMidwayKoaContext = IMidwayContext<KoaContext>;
|
|
10
8
|
export declare type IMidwayKoaApplication = IMidwayApplication<IMidwayKoaContext, koa<DefaultState, IMidwayKoaContext> & {
|
|
@@ -61,6 +59,53 @@ export interface IWebMiddleware {
|
|
|
61
59
|
export declare type Application = IMidwayKoaApplication;
|
|
62
60
|
export interface Context extends IMidwayKoaContext {
|
|
63
61
|
}
|
|
62
|
+
interface BodyParserOptions {
|
|
63
|
+
/**
|
|
64
|
+
* parser will only parse when request type hits enableTypes, default is ['json', 'form'].
|
|
65
|
+
*/
|
|
66
|
+
enableTypes?: string[] | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* requested encoding. Default is utf-8 by co-body
|
|
69
|
+
*/
|
|
70
|
+
encode?: string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* limit of the urlencoded body. If the body ends up being larger than this limit
|
|
73
|
+
* a 413 error code is returned. Default is 56kb
|
|
74
|
+
*/
|
|
75
|
+
formLimit?: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* limit of the json body. Default is 1mb
|
|
78
|
+
*/
|
|
79
|
+
jsonLimit?: string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* limit of the text body. Default is 1mb.
|
|
82
|
+
*/
|
|
83
|
+
textLimit?: string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* limit of the xml body. Default is 1mb.
|
|
86
|
+
*/
|
|
87
|
+
xmlLimit?: string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* when set to true, JSON parser will only accept arrays and objects. Default is true
|
|
90
|
+
*/
|
|
91
|
+
strict?: boolean | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* custom json request detect function. Default is null
|
|
94
|
+
*/
|
|
95
|
+
detectJSON?: ((ctx: IMidwayKoaContext) => boolean) | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* support extend types
|
|
98
|
+
*/
|
|
99
|
+
extendTypes?: {
|
|
100
|
+
json?: string[] | undefined;
|
|
101
|
+
form?: string[] | undefined;
|
|
102
|
+
text?: string[] | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* support custom error handle
|
|
106
|
+
*/
|
|
107
|
+
onerror?: ((err: Error, ctx: IMidwayKoaContext) => void) | undefined;
|
|
108
|
+
}
|
|
64
109
|
declare module '@midwayjs/core/dist/interface' {
|
|
65
110
|
interface MidwayConfig {
|
|
66
111
|
keys?: string | string[];
|
|
@@ -77,7 +122,14 @@ declare module '@midwayjs/core/dist/interface' {
|
|
|
77
122
|
template?: string;
|
|
78
123
|
accepts?: (...args: any[]) => any;
|
|
79
124
|
};
|
|
80
|
-
bodyParser?:
|
|
125
|
+
bodyParser?: BodyParserOptions;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
declare module 'koa' {
|
|
129
|
+
interface Request {
|
|
130
|
+
body?: any;
|
|
131
|
+
rawBody: string;
|
|
81
132
|
}
|
|
82
133
|
}
|
|
134
|
+
export {};
|
|
83
135
|
//# sourceMappingURL=interface.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/koa",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.17",
|
|
4
4
|
"description": "Midway Web Framework for KOA",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "node --require=ts-node/register ../../node_modules/.bin/jest",
|
|
10
|
-
"cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
|
|
9
|
+
"test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
|
|
10
|
+
"cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
|
|
11
11
|
"ci": "npm run test"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
@@ -23,19 +23,18 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@midwayjs/decorator": "^3.0.0-beta.
|
|
26
|
+
"@midwayjs/decorator": "^3.0.0-beta.17",
|
|
27
27
|
"@midwayjs/logger": "2.14.0",
|
|
28
|
-
"@midwayjs/mock": "^3.0.0-beta.
|
|
28
|
+
"@midwayjs/mock": "^3.0.0-beta.17",
|
|
29
29
|
"@types/koa": "2.13.4",
|
|
30
|
-
"@types/koa-bodyparser": "4.3.5",
|
|
31
30
|
"@types/koa-router": "7.4.4",
|
|
32
31
|
"fs-extra": "10.0.0"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@koa/router": "^10.0.0",
|
|
36
35
|
"@midwayjs/cookies": "1.0.1",
|
|
37
|
-
"@midwayjs/core": "^3.0.0-beta.
|
|
38
|
-
"@midwayjs/session": "^3.0.0-beta.
|
|
36
|
+
"@midwayjs/core": "^3.0.0-beta.17",
|
|
37
|
+
"@midwayjs/session": "^3.0.0-beta.17",
|
|
39
38
|
"koa": "2.13.4",
|
|
40
39
|
"koa-bodyparser": "4.3.0",
|
|
41
40
|
"koa-onerror": "^4.1.0"
|
|
@@ -48,5 +47,5 @@
|
|
|
48
47
|
"engines": {
|
|
49
48
|
"node": ">=12"
|
|
50
49
|
},
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "17a8b5bd3d0b0b21f24dd2f165b5df9097fc3ec4"
|
|
52
51
|
}
|