@midwayjs/http-proxy 3.19.0 → 4.0.0-alpha.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.
@@ -24,6 +24,7 @@ let HttpProxyConfiguration = class HttpProxyConfiguration {
24
24
  }
25
25
  }
26
26
  };
27
+ exports.HttpProxyConfiguration = HttpProxyConfiguration;
27
28
  __decorate([
28
29
  (0, core_1.Inject)(),
29
30
  __metadata("design:type", core_1.MidwayApplicationManager)
@@ -32,7 +33,7 @@ __decorate([
32
33
  (0, core_1.Config)('httpProxy'),
33
34
  __metadata("design:type", Object)
34
35
  ], HttpProxyConfiguration.prototype, "httpProxy", void 0);
35
- HttpProxyConfiguration = __decorate([
36
+ exports.HttpProxyConfiguration = HttpProxyConfiguration = __decorate([
36
37
  (0, core_1.Configuration)({
37
38
  namespace: 'http-proxy',
38
39
  importConfigs: [
@@ -42,5 +43,4 @@ HttpProxyConfiguration = __decorate([
42
43
  ],
43
44
  })
44
45
  ], HttpProxyConfiguration);
45
- exports.HttpProxyConfiguration = HttpProxyConfiguration;
46
46
  //# sourceMappingURL=configuration.js.map
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { IMiddleware, IMidwayLogger, IMidwayApplication } from '@midwayjs/core';
2
+ import { IMiddleware, ILogger, IMidwayApplication } from '@midwayjs/core';
3
3
  import { HttpProxyConfig } from './interface';
4
4
  export declare class HttpProxyMiddleware implements IMiddleware<any, any> {
5
5
  httpProxy: HttpProxyConfig;
6
- logger: IMidwayLogger;
6
+ logger: ILogger;
7
7
  resolve(app: IMidwayApplication): (req: any, res: any, next: any) => Promise<any>;
8
8
  execProxy(ctx: any, req: any, res: any, next: any, isServerless: any): Promise<any>;
9
9
  getProxyList(url: any): undefined | {
@@ -22,14 +22,12 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
22
22
  else {
23
23
  const isServerless = app.getNamespace() === 'faas';
24
24
  return async (ctx, next) => {
25
- var _a;
26
- const req = ((_a = ctx.request) === null || _a === void 0 ? void 0 : _a.req) || ctx.request;
25
+ const req = ctx.request?.req || ctx.request;
27
26
  return this.execProxy(ctx, req, ctx, next, isServerless);
28
27
  };
29
28
  }
30
29
  }
31
30
  async execProxy(ctx, req, res, next, isServerless) {
32
- var _a, _b, _c;
33
31
  const proxyInfo = this.getProxyList(ctx.url);
34
32
  if (!proxyInfo) {
35
33
  return next();
@@ -37,7 +35,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
37
35
  const { proxy, url } = proxyInfo;
38
36
  const reqHeaders = {};
39
37
  for (const key of Object.keys(req.headers)) {
40
- if (((_a = proxy.ignoreHeaders) === null || _a === void 0 ? void 0 : _a[key]) || ctx.header[key] === undefined) {
38
+ if (proxy.ignoreHeaders?.[key] || ctx.header[key] === undefined) {
41
39
  continue;
42
40
  }
43
41
  reqHeaders[key.toLowerCase()] = ctx.header[key];
@@ -60,7 +58,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
60
58
  timeout: this.httpProxy.proxyTimeout || 0,
61
59
  };
62
60
  if (method === 'POST' || method === 'PUT') {
63
- reqOptions.data = (_b = req.body) !== null && _b !== void 0 ? _b : (_c = ctx.request) === null || _c === void 0 ? void 0 : _c.body;
61
+ reqOptions.data = req.body ?? ctx.request?.body;
64
62
  if (req.headers['content-type'] === 'application/x-www-form-urlencoded' &&
65
63
  typeof reqOptions.data !== 'string') {
66
64
  reqOptions.data = Object.keys(reqOptions.data)
@@ -147,6 +145,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
147
145
  return 'http-proxy';
148
146
  }
149
147
  };
148
+ exports.HttpProxyMiddleware = HttpProxyMiddleware;
150
149
  __decorate([
151
150
  (0, core_1.Config)('httpProxy'),
152
151
  __metadata("design:type", Object)
@@ -155,8 +154,7 @@ __decorate([
155
154
  (0, core_1.Logger)(),
156
155
  __metadata("design:type", Object)
157
156
  ], HttpProxyMiddleware.prototype, "logger", void 0);
158
- HttpProxyMiddleware = __decorate([
157
+ exports.HttpProxyMiddleware = HttpProxyMiddleware = __decorate([
159
158
  (0, core_1.Middleware)()
160
159
  ], HttpProxyMiddleware);
161
- exports.HttpProxyMiddleware = HttpProxyMiddleware;
162
160
  //# sourceMappingURL=middleware.js.map
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/http-proxy",
3
- "version": "3.19.0",
3
+ "version": "4.0.0-alpha.1",
4
4
  "description": "Midway Component for http proxy",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
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",
9
+ "test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
10
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
11
11
  "ci": "npm run test"
12
12
  },
13
13
  "keywords": [
@@ -26,16 +26,16 @@
26
26
  },
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "axios": "1.7.7"
29
+ "axios": "1.7.9"
30
30
  },
31
31
  "devDependencies": {
32
- "@midwayjs/core": "^3.19.0",
33
- "@midwayjs/express": "^3.19.0",
34
- "@midwayjs/faas": "^3.19.0",
35
- "@midwayjs/koa": "^3.19.0",
36
- "@midwayjs/mock": "^3.19.0",
37
- "@midwayjs/serverless-app": "^3.19.0",
38
- "@midwayjs/web": "^3.19.0"
32
+ "@midwayjs/core": "^4.0.0-alpha.1",
33
+ "@midwayjs/express": "^4.0.0-alpha.1",
34
+ "@midwayjs/faas": "^4.0.0-alpha.1",
35
+ "@midwayjs/koa": "^4.0.0-alpha.1",
36
+ "@midwayjs/mock": "^4.0.0-alpha.1",
37
+ "@midwayjs/web": "^4.0.0-alpha.1",
38
+ "nock": "13.5.5"
39
39
  },
40
- "gitHead": "437e92d9375b0e375f83aa363f3e6a60187c7109"
40
+ "gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
41
41
  }