Skip to content

Commit 520ffd7

Browse files
authored
refactor: fix circular dependencies (#1010)
1 parent 82aaf0a commit 520ffd7

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- fix(logger-plugin): fix missing target port
88
- ci(package): npm package provenance
99
- fix(logger-plugin): log target port when router option is used
10+
- refactor: fix circular dependencies
1011

1112
## [v3.0.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.0)
1213

src/factory.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { HttpProxyMiddleware } from './http-proxy-middleware';
2+
import type { Options, RequestHandler, NextFunction } from './types';
3+
import type * as http from 'http';
4+
5+
export function createProxyMiddleware<
6+
TReq = http.IncomingMessage,
7+
TRes = http.ServerResponse,
8+
TNext = NextFunction,
9+
>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext> {
10+
const { middleware } = new HttpProxyMiddleware<TReq, TRes>(options);
11+
return middleware as unknown as RequestHandler<TReq, TRes, TNext>;
12+
}

src/index.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
import { HttpProxyMiddleware } from './http-proxy-middleware';
2-
import type { Options, RequestHandler, NextFunction } from './types';
3-
import type * as http from 'http';
4-
5-
export function createProxyMiddleware<
6-
TReq = http.IncomingMessage,
7-
TRes = http.ServerResponse,
8-
TNext = NextFunction,
9-
>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext> {
10-
const { middleware } = new HttpProxyMiddleware<TReq, TRes>(options);
11-
return middleware as unknown as RequestHandler<TReq, TRes, TNext>;
12-
}
1+
export * from './factory';
132

143
export * from './handlers';
154

src/legacy/create-proxy-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProxyMiddleware } from '..';
1+
import { createProxyMiddleware } from '../factory';
22
import { Debug } from '../debug';
33
import { Filter, RequestHandler } from '../types';
44
import { legacyOptionsAdapter } from './options-adapter';

src/legacy/options-adapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as url from 'url';
2-
import { Filter, Options } from '..';
2+
import { Filter, Options } from '../types';
33
import { LegacyOptions } from './types';
44
import { Debug } from '../debug';
55
import { getLogger } from '../logger';

src/legacy/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as http from 'http';
2-
import { Options } from '..';
2+
import { Options } from '../types';
33

44
/**
55
* @deprecated

0 commit comments

Comments
 (0)