• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chimurai / http-proxy-middleware / 23962524961

03 Apr 2026 09:16PM UTC coverage: 96.544% (-0.6%) from 97.15%
23962524961

push

github

web-flow
refactor(#1136): replace `http-proxy` w/ `httpxy` (#1160)

* refactor(#1136): replace `http-proxy` w/ `httpxy`

* chore: make prettier happy

* chore: make cspell happy

* refactor: make tests passed

* chore: upgrade to latest httpxy and fix more types

* refactor: make types happy

* chore: make lint happy

* chore: drop outdated patch-package

175 of 191 branches covered (91.62%)

23 of 25 new or added lines in 4 files covered. (92.0%)

1 existing line in 1 file now uncovered.

419 of 434 relevant lines covered (96.54%)

24.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/plugins/default/proxy-events.ts
1
import { Debug } from '../../debug';
12✔
2
import { Plugin } from '../../types';
3
import { getFunctionName } from '../../utils/function';
12✔
4

5
const debug = Debug.extend('proxy-events-plugin');
12✔
6

7
/**
8
 * Implements option.on object to subscribe to http-proxy events.
9
 *
10
 * @example
11
 * ```js
12
 * createProxyMiddleware({
13
 *  on: {
14
 *    error: (error, req, res, target) => {},
15
 *    proxyReq: (proxyReq, req, res, options) => {},
16
 *    proxyReqWs: (proxyReq, req, socket, options) => {},
17
 *    proxyRes: (proxyRes, req, res) => {},
18
 *    open: (proxySocket) => {},
19
 *    close: (proxyRes, proxySocket, proxyHead) => {},
20
 *    start: (req, res, target) => {},
21
 *    end: (req, res, proxyRes) => {},
22
 *    econnreset: (error, req, res, target) => {},
23
 *  }
24
 * });
25
 * ```
26
 */
27
export const proxyEventsPlugin: Plugin = (proxyServer, options) => {
12✔
28
  if (!options.on) {
75✔
29
    return;
55✔
30
  }
31

32
  // hoist variable here for better typing
33
  let eventName: keyof typeof options.on;
34
  // for in provide better typing than Object.entries()
35
  for (eventName in options.on) {
20✔
36
    if (Object.prototype.hasOwnProperty.call(options.on, eventName)) {
42!
37
      const handler = options.on[eventName];
42✔
38
      if (!handler) {
42!
NEW
39
        continue;
×
40
      }
41
      debug(`register event handler: "${eventName}" -> "${getFunctionName(handler)}"`);
42✔
42
      proxyServer.on<keyof typeof options.on>(eventName, handler as (...args: unknown[]) => void);
42✔
43
    }
44
  }
45
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc