http-proxy-middleware 1.3.1 → 2.0.3

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  # http-proxy-middleware
2
2
 
3
- [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/chimurai/http-proxy-middleware/Test/master?style=flat-square)](https://github.com/chimurai/http-proxy-middleware/actions?query=branch%3Amaster)
3
+ [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/chimurai/http-proxy-middleware/CI/master?style=flat-square)](https://github.com/chimurai/http-proxy-middleware/actions?query=branch%3Amaster)
4
4
  [![Coveralls](https://img.shields.io/coveralls/chimurai/http-proxy-middleware.svg?style=flat-square)](https://coveralls.io/r/chimurai/http-proxy-middleware)
5
- [![dependency Status](https://img.shields.io/david/chimurai/http-proxy-middleware.svg?style=flat-square)](https://david-dm.org/chimurai/http-proxy-middleware#info=dependencies)
6
5
  [![dependency Status](https://snyk.io/test/npm/http-proxy-middleware/badge.svg?style=flat-square)](https://snyk.io/test/npm/http-proxy-middleware)
7
6
  [![npm](https://img.shields.io/npm/v/http-proxy-middleware?color=%23CC3534&style=flat-square)](https://www.npmjs.com/package/http-proxy-middleware)
8
7
 
@@ -128,6 +127,7 @@ const express = require('express');
128
127
  const { createProxyMiddleware } = require('http-proxy-middleware');
129
128
 
130
129
  // proxy middleware options
130
+ /** @type {import('http-proxy-middleware/dist/types').Options} */
131
131
  const options = {
132
132
  target: 'http://www.example.org', // target host
133
133
  changeOrigin: true, // needed for virtual hosted sites
@@ -341,7 +341,7 @@ Subscribe to [http-proxy events](https://github.com/nodejitsu/node-http-proxy#li
341
341
  ```javascript
342
342
  function onOpen(proxySocket) {
343
343
  // listen for messages coming FROM the target here
344
- proxySocket.on('data', hybiParseAndLogMessage);
344
+ proxySocket.on('data', hybridParseAndLogMessage);
345
345
  }
346
346
  ```
347
347
 
@@ -586,6 +586,9 @@ $ yarn test
586
586
 
587
587
  # code coverage
588
588
  $ yarn cover
589
+
590
+ # check spelling mistakes
591
+ $ yarn spellcheck
589
592
  ```
590
593
 
591
594
  ## Changelog
@@ -596,4 +599,4 @@ $ yarn cover
596
599
 
597
600
  The MIT License (MIT)
598
601
 
599
- Copyright (c) 2015-2021 Steven Chim
602
+ Copyright (c) 2015-2022 Steven Chim
package/dist/_handlers.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getHandlers = exports.init = void 0;
4
4
  const logger_1 = require("./logger");
5
- const logger = logger_1.getInstance();
5
+ const logger = (0, logger_1.getInstance)();
6
6
  function init(proxy, option) {
7
7
  const handlers = getHandlers(option);
8
8
  for (const eventName of Object.keys(handlers)) {
@@ -66,7 +66,7 @@ function defaultErrorHandler(err, req, res) {
66
66
  }
67
67
  }
68
68
  }
69
- res.end(`Error occured while trying to proxy: ${host}${req.url}`);
69
+ res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
70
70
  }
71
71
  function logClose(req, socket, head) {
72
72
  // view disconnected websocket connections
@@ -5,7 +5,7 @@ const isPlainObj = require("is-plain-obj");
5
5
  const url = require("url");
6
6
  const errors_1 = require("./errors");
7
7
  const logger_1 = require("./logger");
8
- const logger = logger_1.getInstance();
8
+ const logger = (0, logger_1.getInstance)();
9
9
  function createConfig(context, opts) {
10
10
  // structure of config object to be returned
11
11
  const config = {
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { ClientRequest } from 'http';
3
- import type { Request } from '../types';
2
+ import type * as http from 'http';
4
3
  /**
5
4
  * Fix proxied body if bodyParser is involved.
6
5
  */
7
- export declare function fixRequestBody(proxyReq: ClientRequest, req: Request): void;
6
+ export declare function fixRequestBody(proxyReq: http.ClientRequest, req: http.IncomingMessage): void;
@@ -6,7 +6,8 @@ const querystring = require("querystring");
6
6
  * Fix proxied body if bodyParser is involved.
7
7
  */
8
8
  function fixRequestBody(proxyReq, req) {
9
- if (!req.body || !Object.keys(req.body).length) {
9
+ const requestBody = req.body;
10
+ if (!requestBody) {
10
11
  return;
11
12
  }
12
13
  const contentType = proxyReq.getHeader('Content-Type');
@@ -16,10 +17,10 @@ function fixRequestBody(proxyReq, req) {
16
17
  proxyReq.write(bodyData);
17
18
  };
18
19
  if (contentType && contentType.includes('application/json')) {
19
- writeBody(JSON.stringify(req.body));
20
+ writeBody(JSON.stringify(requestBody));
20
21
  }
21
22
  if (contentType === 'application/x-www-form-urlencoded') {
22
- writeBody(querystring.stringify(req.body));
23
+ writeBody(querystring.stringify(requestBody));
23
24
  }
24
25
  }
25
26
  exports.fixRequestBody = fixRequestBody;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.responseInterceptor = void 0;
13
4
  const zlib = require("zlib");
@@ -19,27 +10,25 @@ const zlib = require("zlib");
19
10
  * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())
20
11
  */
21
12
  function responseInterceptor(interceptor) {
22
- return function proxyRes(proxyRes, req, res) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const originalProxyRes = proxyRes;
25
- let buffer = Buffer.from('', 'utf8');
26
- // decompress proxy response
27
- const _proxyRes = decompress(proxyRes, proxyRes.headers['content-encoding']);
28
- // concat data stream
29
- _proxyRes.on('data', (chunk) => (buffer = Buffer.concat([buffer, chunk])));
30
- _proxyRes.on('end', () => __awaiter(this, void 0, void 0, function* () {
31
- // copy original headers
32
- copyHeaders(proxyRes, res);
33
- // call interceptor with intercepted response (buffer)
34
- const interceptedBuffer = Buffer.from(yield interceptor(buffer, originalProxyRes, req, res));
35
- // set correct content-length (with double byte character support)
36
- res.setHeader('content-length', Buffer.byteLength(interceptedBuffer, 'utf8'));
37
- res.write(interceptedBuffer);
38
- res.end();
39
- }));
40
- _proxyRes.on('error', (error) => {
41
- res.end(`Error fetching proxied request: ${error.message}`);
42
- });
13
+ return async function proxyRes(proxyRes, req, res) {
14
+ const originalProxyRes = proxyRes;
15
+ let buffer = Buffer.from('', 'utf8');
16
+ // decompress proxy response
17
+ const _proxyRes = decompress(proxyRes, proxyRes.headers['content-encoding']);
18
+ // concat data stream
19
+ _proxyRes.on('data', (chunk) => (buffer = Buffer.concat([buffer, chunk])));
20
+ _proxyRes.on('end', async () => {
21
+ // copy original headers
22
+ copyHeaders(proxyRes, res);
23
+ // call interceptor with intercepted response (buffer)
24
+ const interceptedBuffer = Buffer.from(await interceptor(buffer, originalProxyRes, req, res));
25
+ // set correct content-length (with double byte character support)
26
+ res.setHeader('content-length', Buffer.byteLength(interceptedBuffer, 'utf8'));
27
+ res.write(interceptedBuffer);
28
+ res.end();
29
+ });
30
+ _proxyRes.on('error', (error) => {
31
+ res.end(`Error fetching proxied request: ${error.message}`);
43
32
  });
44
33
  };
45
34
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.HttpProxyMiddleware = void 0;
13
4
  const httpProxy = require("http-proxy");
@@ -19,15 +10,15 @@ const PathRewriter = require("./path-rewriter");
19
10
  const Router = require("./router");
20
11
  class HttpProxyMiddleware {
21
12
  constructor(context, opts) {
22
- this.logger = logger_1.getInstance();
13
+ this.logger = (0, logger_1.getInstance)();
23
14
  this.wsInternalSubscribed = false;
24
15
  this.serverOnCloseSubscribed = false;
25
16
  // https://github.com/Microsoft/TypeScript/wiki/'this'-in-TypeScript#red-flags-for-this
26
- this.middleware = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
17
+ this.middleware = async (req, res, next) => {
27
18
  var _a, _b;
28
19
  if (this.shouldProxy(this.config.context, req)) {
29
20
  try {
30
- const activeProxyOptions = yield this.prepareProxyRequest(req);
21
+ const activeProxyOptions = await this.prepareProxyRequest(req);
31
22
  this.proxy.web(req, res, activeProxyOptions);
32
23
  }
33
24
  catch (err) {
@@ -57,7 +48,7 @@ class HttpProxyMiddleware {
57
48
  // use initial request to access the server object to subscribe to http upgrade event
58
49
  this.catchUpgradeRequest(server);
59
50
  }
60
- });
51
+ };
61
52
  this.catchUpgradeRequest = (server) => {
62
53
  if (!this.wsInternalSubscribed) {
63
54
  server.on('upgrade', this.handleUpgrade);
@@ -66,13 +57,13 @@ class HttpProxyMiddleware {
66
57
  this.wsInternalSubscribed = true;
67
58
  }
68
59
  };
69
- this.handleUpgrade = (req, socket, head) => __awaiter(this, void 0, void 0, function* () {
60
+ this.handleUpgrade = async (req, socket, head) => {
70
61
  if (this.shouldProxy(this.config.context, req)) {
71
- const activeProxyOptions = yield this.prepareProxyRequest(req);
62
+ const activeProxyOptions = await this.prepareProxyRequest(req);
72
63
  this.proxy.ws(req, socket, head, activeProxyOptions);
73
64
  this.logger.info('[HPM] Upgrading to WebSocket');
74
65
  }
75
- });
66
+ };
76
67
  /**
77
68
  * Determine whether request should be proxied.
78
69
  *
@@ -93,7 +84,7 @@ class HttpProxyMiddleware {
93
84
  * @param {Object} req
94
85
  * @return {Object} proxy options
95
86
  */
96
- this.prepareProxyRequest = (req) => __awaiter(this, void 0, void 0, function* () {
87
+ this.prepareProxyRequest = async (req) => {
97
88
  // https://github.com/chimurai/http-proxy-middleware/issues/17
98
89
  // https://github.com/chimurai/http-proxy-middleware/issues/94
99
90
  req.url = req.originalUrl || req.url;
@@ -103,30 +94,30 @@ class HttpProxyMiddleware {
103
94
  // Apply in order:
104
95
  // 1. option.router
105
96
  // 2. option.pathRewrite
106
- yield this.applyRouter(req, newProxyOptions);
107
- yield this.applyPathRewrite(req, this.pathRewriter);
97
+ await this.applyRouter(req, newProxyOptions);
98
+ await this.applyPathRewrite(req, this.pathRewriter);
108
99
  // debug logging for both http(s) and websockets
109
100
  if (this.proxyOptions.logLevel === 'debug') {
110
- const arrow = logger_1.getArrow(originalPath, req.url, this.proxyOptions.target, newProxyOptions.target);
101
+ const arrow = (0, logger_1.getArrow)(originalPath, req.url, this.proxyOptions.target, newProxyOptions.target);
111
102
  this.logger.debug('[HPM] %s %s %s %s', req.method, originalPath, arrow, newProxyOptions.target);
112
103
  }
113
104
  return newProxyOptions;
114
- });
105
+ };
115
106
  // Modify option.target when router present.
116
- this.applyRouter = (req, options) => __awaiter(this, void 0, void 0, function* () {
107
+ this.applyRouter = async (req, options) => {
117
108
  let newTarget;
118
109
  if (options.router) {
119
- newTarget = yield Router.getTarget(req, options);
110
+ newTarget = await Router.getTarget(req, options);
120
111
  if (newTarget) {
121
112
  this.logger.debug('[HPM] Router new target: %s -> "%s"', options.target, newTarget);
122
113
  options.target = newTarget;
123
114
  }
124
115
  }
125
- });
116
+ };
126
117
  // rewrite path
127
- this.applyPathRewrite = (req, pathRewriter) => __awaiter(this, void 0, void 0, function* () {
118
+ this.applyPathRewrite = async (req, pathRewriter) => {
128
119
  if (pathRewriter) {
129
- const path = yield pathRewriter(req.url, req);
120
+ const path = await pathRewriter(req.url, req);
130
121
  if (typeof path === 'string') {
131
122
  req.url = path;
132
123
  }
@@ -134,7 +125,7 @@ class HttpProxyMiddleware {
134
125
  this.logger.info('[HPM] pathRewrite: No rewritten path found. (%s)', req.url);
135
126
  }
136
127
  }
137
- });
128
+ };
138
129
  this.logError = (err, req, res, target) => {
139
130
  var _a;
140
131
  const hostname = ((_a = req.headers) === null || _a === void 0 ? void 0 : _a.host) || req.hostname || req.host; // (websocket) || (node0.10 || node 4/5)
@@ -144,7 +135,7 @@ class HttpProxyMiddleware {
144
135
  const errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors'; // link to Node Common Systems Errors page
145
136
  this.logger.error(errorMessage, requestHref, targetHref, err.code || err, errReference);
146
137
  };
147
- this.config = config_factory_1.createConfig(context, opts);
138
+ this.config = (0, config_factory_1.createConfig)(context, opts);
148
139
  this.proxyOptions = this.config.options;
149
140
  // create proxy
150
141
  this.proxy = httpProxy.createProxyServer({});
@@ -4,7 +4,7 @@ exports.createPathRewriter = void 0;
4
4
  const isPlainObj = require("is-plain-obj");
5
5
  const errors_1 = require("./errors");
6
6
  const logger_1 = require("./logger");
7
- const logger = logger_1.getInstance();
7
+ const logger = (0, logger_1.getInstance)();
8
8
  /**
9
9
  * Create rewrite function, to cache parsed rewrite rules.
10
10
  *
package/dist/router.js CHANGED
@@ -1,30 +1,19 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getTarget = void 0;
13
4
  const isPlainObj = require("is-plain-obj");
14
5
  const logger_1 = require("./logger");
15
- const logger = logger_1.getInstance();
16
- function getTarget(req, config) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- let newTarget;
19
- const router = config.router;
20
- if (isPlainObj(router)) {
21
- newTarget = getTargetFromProxyTable(req, router);
22
- }
23
- else if (typeof router === 'function') {
24
- newTarget = yield router(req);
25
- }
26
- return newTarget;
27
- });
6
+ const logger = (0, logger_1.getInstance)();
7
+ async function getTarget(req, config) {
8
+ let newTarget;
9
+ const router = config.router;
10
+ if (isPlainObj(router)) {
11
+ newTarget = getTargetFromProxyTable(req, router);
12
+ }
13
+ else if (typeof router === 'function') {
14
+ newTarget = await router(req);
15
+ }
16
+ return newTarget;
28
17
  }
29
18
  exports.getTarget = getTarget;
30
19
  function getTargetFromProxyTable(req, table) {
package/dist/types.d.ts CHANGED
@@ -1,8 +1,13 @@
1
+ /**
2
+ * Based on definition by DefinitelyTyped:
3
+ * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
4
+ */
1
5
  /// <reference types="node" />
2
- import * as express from 'express';
3
- import * as http from 'http';
4
- import * as httpProxy from 'http-proxy';
5
- import * as net from 'net';
6
+ import type * as express from 'express';
7
+ import type * as http from 'http';
8
+ import type * as httpProxy from 'http-proxy';
9
+ import type * as net from 'net';
10
+ import type * as url from 'url';
6
11
  export interface Request extends express.Request {
7
12
  }
8
13
  export interface Response extends express.Response {
@@ -19,13 +24,13 @@ export interface Options extends httpProxy.ServerOptions {
19
24
  [hostOrPath: string]: httpProxy.ServerOptions['target'];
20
25
  } | ((req: Request) => httpProxy.ServerOptions['target']) | ((req: Request) => Promise<httpProxy.ServerOptions['target']>);
21
26
  logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
22
- logProvider?(provider: LogProvider): LogProvider;
23
- onError?(err: Error, req: Request, res: Response): void;
24
- onProxyRes?(proxyRes: http.IncomingMessage, req: Request, res: Response): void;
25
- onProxyReq?(proxyReq: http.ClientRequest, req: Request, res: Response): void;
26
- onProxyReqWs?(proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: httpProxy.ServerOptions, head: any): void;
27
- onOpen?(proxySocket: net.Socket): void;
28
- onClose?(res: Response, socket: net.Socket, head: any): void;
27
+ logProvider?: LogProviderCallback;
28
+ onError?: OnErrorCallback;
29
+ onProxyRes?: OnProxyResCallback;
30
+ onProxyReq?: OnProxyReqCallback;
31
+ onProxyReqWs?: OnProxyReqWsCallback;
32
+ onOpen?: OnOpenCallback;
33
+ onClose?: OnCloseCallback;
29
34
  }
30
35
  interface LogProvider {
31
36
  log: Logger;
@@ -35,4 +40,15 @@ interface LogProvider {
35
40
  error?: Logger;
36
41
  }
37
42
  declare type Logger = (...args: any[]) => void;
43
+ export declare type LogProviderCallback = (provider: LogProvider) => LogProvider;
44
+ /**
45
+ * Use types based on the events listeners from http-proxy
46
+ * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/51504fd999031b7f025220fab279f1b2155cbaff/types/http-proxy/index.d.ts
47
+ */
48
+ export declare type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
49
+ export declare type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
50
+ export declare type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: httpProxy.ServerOptions) => void;
51
+ export declare type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: httpProxy.ServerOptions, head: any) => void;
52
+ export declare type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
53
+ export declare type OnOpenCallback = (proxySocket: net.Socket) => void;
38
54
  export {};
package/dist/types.js CHANGED
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-empty-interface */
2
+ /**
3
+ * Based on definition by DefinitelyTyped:
4
+ * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
5
+ */
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-proxy-middleware",
3
- "version": "1.3.1",
3
+ "version": "2.0.3",
4
4
  "description": "The one-liner node.js proxy middleware for connect, express and browser-sync",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,11 @@
19
19
  "build": "tsc",
20
20
  "pretest": "yarn build",
21
21
  "test": "jest",
22
+ "precoverage": "yarn build",
22
23
  "coverage": "jest --coverage --coverageReporters=lcov",
23
- "prepare": "yarn build && rm dist/tsconfig.tsbuildinfo"
24
+ "prepare": "husky install",
25
+ "prepack": "yarn build && rm dist/tsconfig.tsbuildinfo",
26
+ "spellcheck": "npx --yes cspell --show-context --show-suggestions '**/*.*'"
24
27
  },
25
28
  "repository": {
26
29
  "type": "git",
@@ -50,51 +53,54 @@
50
53
  },
51
54
  "homepage": "https://github.com/chimurai/http-proxy-middleware#readme",
52
55
  "devDependencies": {
53
- "@commitlint/cli": "^12.0.1",
54
- "@commitlint/config-conventional": "^12.0.1",
55
- "@types/express": "4.17.7",
56
- "@types/is-glob": "^4.0.1",
57
- "@types/jest": "^26.0.22",
58
- "@types/micromatch": "^4.0.1",
59
- "@types/node": "^14.14.37",
60
- "@types/supertest": "^2.0.10",
61
- "@types/ws": "^7.4.0",
62
- "@typescript-eslint/eslint-plugin": "^4.19.0",
63
- "@typescript-eslint/parser": "^4.19.0",
64
- "body-parser": "^1.19.0",
65
- "browser-sync": "^2.26.14",
66
- "connect": "^3.7.0",
67
- "eslint": "^7.23.0",
68
- "eslint-config-prettier": "^8.1.0",
69
- "eslint-plugin-prettier": "^3.3.1",
70
- "express": "^4.17.1",
71
- "husky": "^4.3.0",
72
- "jest": "^26.6.3",
73
- "lint-staged": "^10.5.4",
74
- "mockttp": "^1.2.0",
75
- "open": "^7.4.2",
76
- "prettier": "^2.2.1",
77
- "supertest": "^6.1.3",
78
- "ts-jest": "^26.5.4",
79
- "typescript": "^4.2.3",
80
- "ws": "^7.4.4"
56
+ "@commitlint/cli": "16.1.0",
57
+ "@commitlint/config-conventional": "16.0.0",
58
+ "@types/express": "4.17.13",
59
+ "@types/is-glob": "4.0.2",
60
+ "@types/jest": "27.4.0",
61
+ "@types/micromatch": "4.0.2",
62
+ "@types/node": "17.0.10",
63
+ "@types/supertest": "2.0.11",
64
+ "@types/ws": "8.2.2",
65
+ "@typescript-eslint/eslint-plugin": "5.10.0",
66
+ "@typescript-eslint/parser": "5.10.0",
67
+ "body-parser": "1.19.1",
68
+ "browser-sync": "2.27.7",
69
+ "connect": "3.7.0",
70
+ "eslint": "8.7.0",
71
+ "eslint-config-prettier": "8.3.0",
72
+ "eslint-plugin-prettier": "4.0.0",
73
+ "express": "4.17.2",
74
+ "get-port": "5.1.1",
75
+ "husky": "7.0.4",
76
+ "jest": "27.4.7",
77
+ "lint-staged": "12.2.2",
78
+ "mockttp": "2.5.1",
79
+ "open": "8.4.0",
80
+ "prettier": "2.5.1",
81
+ "supertest": "6.2.2",
82
+ "ts-jest": "27.1.3",
83
+ "typescript": "4.5.5",
84
+ "ws": "8.4.2"
81
85
  },
82
86
  "dependencies": {
83
- "@types/http-proxy": "^1.17.5",
87
+ "@types/http-proxy": "^1.17.8",
84
88
  "http-proxy": "^1.18.1",
85
89
  "is-glob": "^4.0.1",
86
90
  "is-plain-obj": "^3.0.0",
87
91
  "micromatch": "^4.0.2"
88
92
  },
89
- "engines": {
90
- "node": ">=8.0.0"
93
+ "peerDependencies": {
94
+ "@types/express": "^4.17.13"
91
95
  },
92
- "husky": {
93
- "hooks": {
94
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
95
- "pre-commit": "lint-staged"
96
+ "peerDependenciesMeta": {
97
+ "@types/express": {
98
+ "optional": true
96
99
  }
97
100
  },
101
+ "engines": {
102
+ "node": ">=12.0.0"
103
+ },
98
104
  "commitlint": {
99
105
  "extends": [
100
106
  "@commitlint/config-conventional"
package/CHANGELOG.md DELETED
@@ -1,218 +0,0 @@
1
- # Changelog
2
-
3
- ## [v1.3.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.3.1)
4
-
5
- - fix(fix-request-body): make sure the content-type exists ([#578](https://github.com/chimurai/http-proxy-middleware/pull/578)) ([oufeng](https://github.com/oufeng))
6
-
7
- ## [v1.3.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.3.0)
8
-
9
- - docs(response interceptor): align with nodejs default utf8 ([#567](https://github.com/chimurai/http-proxy-middleware/pull/567))
10
- - feat: try to proxy body even after body-parser middleware ([#492](https://github.com/chimurai/http-proxy-middleware/pull/492)) ([midgleyc](https://github.com/midgleyc))
11
-
12
- ## [v1.2.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.2.1)
13
-
14
- - fix(response interceptor): proxy original response headers ([#563](https://github.com/chimurai/http-proxy-middleware/pull/563))
15
-
16
- ## [v1.2.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.2.0)
17
-
18
- - feat(handler): response interceptor ([#520](https://github.com/chimurai/http-proxy-middleware/pull/520))
19
- - fix(log error): handle undefined target when websocket errors ([#527](https://github.com/chimurai/http-proxy-middleware/pull/527))
20
-
21
- ## [v1.1.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.1.2)
22
-
23
- - fix(log error): handle optional target ([#523](https://github.com/chimurai/http-proxy-middleware/pull/523))
24
-
25
- ## [v1.1.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.1.1)
26
-
27
- - fix(error handler): re-throw http-proxy missing target error ([#517](https://github.com/chimurai/http-proxy-middleware/pull/517))
28
- - refactor(dependency): remove `camelcase`
29
- - fix(option): optional `target` when `router` is used ([#512](https://github.com/chimurai/http-proxy-middleware/pull/512))
30
-
31
- ## [v1.1.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.1.0)
32
-
33
- - fix(errorHandler): fix confusing error message ([#509](https://github.com/chimurai/http-proxy-middleware/pull/509))
34
- - fix(proxy): close proxy when server closes ([#508](https://github.com/chimurai/http-proxy-middleware/pull/508))
35
- - refactor(lodash): remove lodash ([#459](https://github.com/chimurai/http-proxy-middleware/pull/459)) ([#507](https://github.com/chimurai/http-proxy-middleware/pull/507)) ([TrySound](https://github.com/TrySound))
36
- - fix(ETIMEDOUT): return 504 on ETIMEDOUT ([#480](https://github.com/chimurai/http-proxy-middleware/pull/480)) ([aremishevsky](https://github.com/aremishevsky))
37
-
38
- ## [v1.0.6](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.6)
39
-
40
- - chore(deps): lodash 4.17.20 ([#475](https://github.com/chimurai/http-proxy-middleware/pull/475))
41
-
42
- ## [v1.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.6)
43
-
44
- - chore(deps): lodash 4.17.19 ([#454](https://github.com/chimurai/http-proxy-middleware/pull/454))
45
-
46
- ## [v1.0.4](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.4)
47
-
48
- - chore(deps): http-proxy 1.18.1 ([#442](https://github.com/chimurai/http-proxy-middleware/pull/442))
49
-
50
- ## [v1.0.3](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.3)
51
-
52
- - build(package): exclude build artifact tsconfig.tsbuildinfo ([#415](https://github.com/chimurai/http-proxy-middleware/pull/415))
53
-
54
- ## [v1.0.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.2)
55
-
56
- - fix(router): handle rejected promise in custom router ([#410](https://github.com/chimurai/http-proxy-middleware/pull/413)) ([bforbis](https://github.com/bforbis))
57
-
58
- ## [v1.0.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.1)
59
-
60
- - fix(typescript): fix proxyRes and router types ([#410](https://github.com/chimurai/http-proxy-middleware/issues/410)) ([dylang](https://github.com/dylang))
61
-
62
- ## [v1.0.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v1.0.0)
63
-
64
- - feat(createProxyMiddleware): explicit import http-proxy-middleware ([BREAKING CHANGE](https://github.com/chimurai/http-proxy-middleware/releases))([#400](https://github.com/chimurai/http-proxy-middleware/issues/400#issuecomment-587162378))
65
- - feat(typescript): export http-proxy-middleware types ([#400](https://github.com/chimurai/http-proxy-middleware/issues/400))
66
- - fix(typescript): ES6 target - TS1192 ([#400](https://github.com/chimurai/http-proxy-middleware/issues/400#issuecomment-587064349))
67
-
68
- ## [v0.21.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.21.0)
69
-
70
- - feat(http-proxy): bump to v1.18.0
71
- - feat: async router ([#379](https://github.com/chimurai/http-proxy-middleware/issues/379)) ([LiranBri](https://github.com/LiranBri))
72
- - feat(typescript): types support ([#369](https://github.com/chimurai/http-proxy-middleware/pull/369))
73
- - feat: async pathRewrite ([#397](https://github.com/chimurai/http-proxy-middleware/pull/397)) ([rsethc](https://github.com/rsethc))
74
-
75
- ## [v0.20.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.20.0)
76
-
77
- - fix(ws): concurrent websocket requests do not get upgraded ([#335](https://github.com/chimurai/http-proxy-middleware/issues/335))
78
- - chore: drop node 6 (BREAKING CHANGE)
79
- - chore: update to micromatch@4 ([BREAKING CHANGE](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md#400---2019-03-20))
80
- - chore: update dev dependencies
81
- - refactor: migrate to typescript ([#328](https://github.com/chimurai/http-proxy-middleware/pull/328))
82
- - feat(middleware): Promise / async support ([#328](https://github.com/chimurai/http-proxy-middleware/pull/328/files#diff-7890bfeb41abb0fc0ef2670749c84077R50))
83
- - refactor: remove legacy options `proxyHost` and `proxyTable` (BREAKING CHANGE)
84
-
85
- ## [v0.19.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.19.1)
86
-
87
- - fix(log): handle case when error code is missing ([#303](https://github.com/chimurai/http-proxy-middleware/pull/303))
88
-
89
- ## [v0.19.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.19.0)
90
-
91
- - feat(http-proxy): bump to v1.17.0 ([#261](https://github.com/chimurai/http-proxy-middleware/pull/261))
92
-
93
- ## [v0.18.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.18.0)
94
-
95
- - fix(vulnerability): update micromatch to v3.x ([npm:braces:20180219](https://snyk.io/test/npm/http-proxy-middleware?tab=issues&severity=high&severity=medium&severity=low#npm:braces:20180219))
96
- - test(node): drop node 0.x support ([#212](https://github.com/chimurai/http-proxy-middleware/pull/212))
97
-
98
- ## [v0.17.4](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.4)
99
-
100
- - fix(ntlm authentication): fixed bug preventing proxying with ntlm authentication. ([#132](https://github.com/chimurai/http-proxy-middleware/pull/149)) (Thanks: [EladBezalel](https://github.com/EladBezalel), [oshri551](https://github.com/oshri551))
101
-
102
- ## [v0.17.3](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.3)
103
-
104
- - fix(onError): improve default proxy error handling. http status codes (504, 502 and 500). ([#132](https://github.com/chimurai/http-proxy-middleware/pull/132)) ([graingert](https://github.com/graingert))
105
-
106
- ## [v0.17.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.2)
107
-
108
- - feat(logging): improve error message & add link to Node errors page. ([#106](https://github.com/chimurai/http-proxy-middleware/pull/106)) ([cloudmu](https://github.com/cloudmu))
109
- - feat(pathRewrite): path can be empty string. ([#110](https://github.com/chimurai/http-proxy-middleware/pull/110)) ([sunnylqm](https://github.com/sunnylqm))
110
- - bug(websocket): memory leak when option 'ws:true' is used. ([#114](https://github.com/chimurai/http-proxy-middleware/pull/114)) ([julbra](https://github.com/julbra))
111
- - chore(package.json): reduce package size. ([#109](https://github.com/chimurai/http-proxy-middleware/pull/109))
112
-
113
- ## [v0.17.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.1)
114
-
115
- - fix(Express sub Router): 404 on non-proxy routes ([#94](https://github.com/chimurai/http-proxy-middleware/issues/94))
116
-
117
- ## [v0.17.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.0)
118
-
119
- - fix(context matching): Use [RFC 3986 path](https://tools.ietf.org/html/rfc3986#section-3.3) in context matching. (excludes query parameters)
120
-
121
- ## [v0.16.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.16.0)
122
-
123
- - deprecated(proxyTable): renamed `proxyTable` to `router`.
124
- - feat(router): support for custom `router` function.
125
-
126
- ## [v0.15.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.15.2)
127
-
128
- - fix(websocket): fixes websocket upgrade.
129
-
130
- ## [v0.15.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.15.1)
131
-
132
- - feat(pathRewrite): expose `req` object to pathRewrite function.
133
- - fix(websocket): fixes websocket upgrade when both config.ws and external .upgrade() are used.
134
-
135
- ## [v0.15.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.15.0)
136
-
137
- - feat(pathRewrite): support for custom pathRewrite function.
138
-
139
- ## [v0.14.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.14.0)
140
-
141
- - feat(proxy): support proxy creation without context.
142
- - fix(connect mounting): use connect's `path` configuration to mount proxy.
143
-
144
- ## [v0.13.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.13.0)
145
-
146
- - feat(context): custom context matcher; when simple `path` matching is not sufficient.
147
-
148
- ## [v0.12.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.12.0)
149
-
150
- - add option `onProxyReqWs` (subscribe to http-proxy `proxyReqWs` event)
151
- - add option `onOpen` (subscribe to http-proxy `open` event)
152
- - add option `onClose` (subscribe to http-proxy `close` event)
153
-
154
- ## [v0.11.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.11.0)
155
-
156
- - improved logging
157
-
158
- ## [v0.10.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.10.0)
159
-
160
- - feat(proxyTable) - added proxyTable support for WebSockets.
161
- - fixed(proxyTable) - ensure original path (not rewritten path) is being used when `proxyTable` is used in conjunction with `pathRewrite`.
162
-
163
- ## [v0.9.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.9.1)
164
-
165
- - fix server crash when socket error not handled correctly.
166
-
167
- ## [v0.9.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.9.0)
168
-
169
- - support subscribing to http-proxy `proxyReq` event ([trbngr](https://github.com/trbngr))
170
- - add `logLevel` and `logProvider` support
171
-
172
- ## [v0.8.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.2)
173
-
174
- - fix proxyError handler ([mTazelaar](https://github.com/mTazelaar))
175
-
176
- ## [v0.8.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.1)
177
-
178
- - fix pathRewrite when `agent` is configured
179
-
180
- ## [v0.8.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.0)
181
-
182
- - support external websocket upgrade
183
- - fix websocket shorthand
184
-
185
- ## [v0.7.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.7.0)
186
-
187
- - support shorthand syntax
188
- - fix express/connect mounting
189
-
190
- ## [v0.6.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.6.0)
191
-
192
- - support proxyTable
193
-
194
- ## [v0.5.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.5.0)
195
-
196
- - support subscribing to http-proxy `error` event
197
- - support subscribing to http-proxy `proxyRes` event
198
-
199
- ## [v0.4.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.4.0)
200
-
201
- - support websocket
202
-
203
- ## [v0.3.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.3.0)
204
-
205
- - support wildcard / glob
206
-
207
- ## [v0.2.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.2.0)
208
-
209
- - support multiple paths
210
-
211
- ## [v0.1.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.1.0)
212
-
213
- - support path rewrite
214
- - deprecate proxyHost option
215
-
216
- ## [v0.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.0.5)
217
-
218
- - initial release