@midwayjs/http-proxy 3.2.0 → 3.2.1
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/README.md +10 -10
- package/dist/interface.d.ts +8 -2
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +8 -1
- package/index.d.ts +2 -2
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@ HTTP 代理组件
|
|
|
7
7
|
### Usage
|
|
8
8
|
|
|
9
9
|
1. 安装依赖
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm i @midwayjs/http-proxy --save
|
|
12
13
|
```
|
|
14
|
+
|
|
13
15
|
2. 在 configuration 中引入组件,
|
|
14
16
|
```ts
|
|
15
17
|
import * as proxy from '@midwayjs/http-proxy';
|
|
@@ -25,11 +27,9 @@ export class AutoConfiguration {}
|
|
|
25
27
|
### 配置
|
|
26
28
|
|
|
27
29
|
```ts
|
|
28
|
-
export const httpProxy =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]
|
|
35
|
-
```
|
|
30
|
+
export const httpProxy = {
|
|
31
|
+
host: 'http://127.0.0.1',
|
|
32
|
+
match: /\/assets\/(.*)/,
|
|
33
|
+
target: 'http://127.0.0.1/$1',
|
|
34
|
+
}
|
|
35
|
+
```
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
match
|
|
1
|
+
export interface HttpProxyStrategy {
|
|
2
|
+
match?: RegExp;
|
|
3
3
|
host?: string;
|
|
4
4
|
target?: string;
|
|
5
5
|
ignoreHeaders?: {
|
|
6
6
|
[key: string]: boolean;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
export interface HttpProxyConfig extends HttpProxyStrategy {
|
|
10
|
+
default?: HttpProxyStrategy;
|
|
11
|
+
strategy?: {
|
|
12
|
+
[strategyName: string]: HttpProxyStrategy;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
9
15
|
//# sourceMappingURL=interface.d.ts.map
|
package/dist/middleware.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { IMiddleware, IMidwayLogger } from '@midwayjs/core';
|
|
3
3
|
import { HttpProxyConfig } from './interface';
|
|
4
4
|
export declare class HttpProxyMiddleware implements IMiddleware<any, any> {
|
|
5
|
-
httpProxy: HttpProxyConfig
|
|
5
|
+
httpProxy: HttpProxyConfig;
|
|
6
6
|
logger: IMidwayLogger;
|
|
7
7
|
resolve(app: any): (req: any, res: any, next: any) => Promise<any>;
|
|
8
8
|
execProxy(ctx: any, req: any, res: any, next: any, isExpress: any): Promise<any>;
|
package/dist/middleware.js
CHANGED
|
@@ -90,7 +90,14 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
|
|
|
90
90
|
if (!this.httpProxy) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
this.httpProxy.default = this.httpProxy.default || {};
|
|
94
|
+
const proxyList = this.httpProxy.match
|
|
95
|
+
? [this.httpProxy]
|
|
96
|
+
: this.httpProxy.strategy
|
|
97
|
+
? Object.values(this.httpProxy.strategy).map(item => {
|
|
98
|
+
return Object.assign({}, this.httpProxy.default, item);
|
|
99
|
+
})
|
|
100
|
+
: [];
|
|
94
101
|
for (const proxy of proxyList) {
|
|
95
102
|
if (!proxy.match) {
|
|
96
103
|
continue;
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpProxyConfig } from './dist/index';
|
|
2
2
|
export * from './dist/index';
|
|
3
3
|
|
|
4
|
-
declare module '@midwayjs/core' {
|
|
4
|
+
declare module '@midwayjs/core/dist/interface' {
|
|
5
5
|
interface MidwayConfig {
|
|
6
|
-
httpProxy?: Partial<HttpProxyConfig
|
|
6
|
+
httpProxy?: Partial<HttpProxyConfig>;
|
|
7
7
|
}
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/http-proxy",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Midway Component for http proxy",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
|
|
11
11
|
"ci": "npm run test"
|
|
12
12
|
},
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"midway",
|
|
15
|
+
"http",
|
|
16
|
+
"proxy"
|
|
17
|
+
],
|
|
14
18
|
"author": "",
|
|
15
19
|
"files": [
|
|
16
20
|
"dist/**/*.js",
|
|
@@ -27,12 +31,12 @@
|
|
|
27
31
|
"devDependencies": {
|
|
28
32
|
"@midwayjs/core": "^3.2.0",
|
|
29
33
|
"@midwayjs/decorator": "^3.0.10",
|
|
30
|
-
"@midwayjs/express": "^3.2.
|
|
34
|
+
"@midwayjs/express": "^3.2.1",
|
|
31
35
|
"@midwayjs/faas": "^3.2.0",
|
|
32
|
-
"@midwayjs/koa": "^3.2.
|
|
36
|
+
"@midwayjs/koa": "^3.2.1",
|
|
33
37
|
"@midwayjs/mock": "^3.2.0",
|
|
34
|
-
"@midwayjs/serverless-app": "^3.2.
|
|
35
|
-
"@midwayjs/web": "^3.2.
|
|
38
|
+
"@midwayjs/serverless-app": "^3.2.1",
|
|
39
|
+
"@midwayjs/web": "^3.2.1"
|
|
36
40
|
},
|
|
37
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "e957e25e353a2e4c56d5ddcce24bb55a10f007ca"
|
|
38
42
|
}
|