@midwayjs/koa 3.2.0 → 3.3.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/framework.js CHANGED
@@ -41,6 +41,10 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
41
41
  const cookieOptions = this.configService.getConfiguration('cookies');
42
42
  this.app = new koa({
43
43
  keys: [].concat(appKeys),
44
+ proxy: this.configurationOptions.proxy,
45
+ proxyIpHeader: this.configurationOptions.proxyIpHeader,
46
+ subdomainOffset: this.configurationOptions.subdomainOffset,
47
+ maxIpsCount: this.configurationOptions.maxIpsCount,
44
48
  });
45
49
  Object.defineProperty(this.app.context, 'cookies', {
46
50
  get() {
@@ -50,6 +50,22 @@ export interface IMidwayKoaConfigurationOptions extends IConfigurationOptions {
50
50
  * http global prefix
51
51
  */
52
52
  globalPrefix?: string;
53
+ /**
54
+ * Trust proxy headers
55
+ */
56
+ proxy?: boolean;
57
+ /**
58
+ * Subdomain offset
59
+ */
60
+ subdomainOffset?: number;
61
+ /**
62
+ * Proxy IP header, defaults to X-Forwarded-For
63
+ */
64
+ proxyIpHeader?: string;
65
+ /**
66
+ * Max IPs read from proxy IP header, default to 0 (means infinity)
67
+ */
68
+ maxIpsCount?: number;
53
69
  }
54
70
  export declare type MiddlewareParamArray = Array<Middleware<DefaultState, IMidwayKoaContext>>;
55
71
  export interface IWebMiddleware {
@@ -92,18 +108,18 @@ export interface BodyParserOptions {
92
108
  /**
93
109
  * custom json request detect function. Default is null
94
110
  */
95
- detectJSON?: ((ctx: IMidwayKoaContext) => boolean);
111
+ detectJSON?: (ctx: IMidwayKoaContext) => boolean;
96
112
  /**
97
113
  * support extend types
98
114
  */
99
115
  extendTypes?: {
100
- json?: string[];
101
- form?: string[];
102
- text?: string[];
116
+ json?: string[] | string | undefined;
117
+ form?: string[] | string | undefined;
118
+ text?: string[] | string | undefined;
103
119
  };
104
120
  /**
105
121
  * support custom error handle
106
122
  */
107
- onerror?: ((err: Error, ctx: IMidwayKoaContext) => void);
123
+ onerror?: (err: Error, ctx: IMidwayKoaContext) => void;
108
124
  }
109
125
  //# sourceMappingURL=interface.d.ts.map
package/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  export * from './dist/index';
8
8
 
9
- declare module '@midwayjs/core' {
9
+ declare module '@midwayjs/core/dist/interface' {
10
10
  interface MidwayConfig {
11
11
  keys?: string | string[];
12
12
  koa?: IMidwayKoaConfigurationOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/koa",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Midway Web Framework for KOA",
5
5
  "main": "dist/index",
6
6
  "typings": "index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@midwayjs/decorator": "^3.1.6",
28
28
  "@midwayjs/logger": "^2.15.0",
29
- "@midwayjs/mock": "^3.2.0",
29
+ "@midwayjs/mock": "^3.3.0",
30
30
  "@types/koa": "2.13.4",
31
31
  "@types/koa-router": "7.4.4",
32
32
  "fs-extra": "10.0.1"
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@koa/router": "^10.0.0",
36
36
  "@midwayjs/cookies": "^1.0.2",
37
- "@midwayjs/core": "^3.2.0",
38
- "@midwayjs/session": "^3.2.0",
37
+ "@midwayjs/core": "^3.3.0",
38
+ "@midwayjs/session": "^3.3.0",
39
39
  "koa": "2.13.4",
40
40
  "koa-bodyparser": "4.3.0"
41
41
  },
@@ -47,5 +47,5 @@
47
47
  "engines": {
48
48
  "node": ">=12"
49
49
  },
50
- "gitHead": "cee3e5ddbb4f0cc5f80176a7b1e271e809686a97"
50
+ "gitHead": "b12b41188879296f9863265baa5bbdb4158bddc5"
51
51
  }