@midwayjs/http-proxy 3.0.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/LICENSE +21 -0
- 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 +15 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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.
|
|
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",
|
|
@@ -25,13 +29,14 @@
|
|
|
25
29
|
"axios": "^0.26.0"
|
|
26
30
|
},
|
|
27
31
|
"devDependencies": {
|
|
28
|
-
"@midwayjs/core": "^3.
|
|
32
|
+
"@midwayjs/core": "^3.2.0",
|
|
29
33
|
"@midwayjs/decorator": "^3.0.10",
|
|
30
|
-
"@midwayjs/express": "^3.1
|
|
31
|
-
"@midwayjs/faas": "^3.
|
|
32
|
-
"@midwayjs/koa": "^3.1
|
|
33
|
-
"@midwayjs/mock": "^3.
|
|
34
|
-
"@midwayjs/serverless-app": "^3.1
|
|
35
|
-
"@midwayjs/web": "^3.1
|
|
36
|
-
}
|
|
34
|
+
"@midwayjs/express": "^3.2.1",
|
|
35
|
+
"@midwayjs/faas": "^3.2.0",
|
|
36
|
+
"@midwayjs/koa": "^3.2.1",
|
|
37
|
+
"@midwayjs/mock": "^3.2.0",
|
|
38
|
+
"@midwayjs/serverless-app": "^3.2.1",
|
|
39
|
+
"@midwayjs/web": "^3.2.1"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "e957e25e353a2e4c56d5ddcce24bb55a10f007ca"
|
|
37
42
|
}
|