diff --git a/src/factory.ts b/src/factory.ts new file mode 100644 index 00000000..2ef0b6d3 --- /dev/null +++ b/src/factory.ts @@ -0,0 +1,12 @@ +import { HttpProxyMiddleware } from './http-proxy-middleware'; +import type { Options, RequestHandler, NextFunction } from './types'; +import type * as http from 'http'; + +export function createProxyMiddleware< + TReq = http.IncomingMessage, + TRes = http.ServerResponse, + TNext = NextFunction, +>(options: Options): RequestHandler { + const { middleware } = new HttpProxyMiddleware(options); + return middleware as unknown as RequestHandler; +} diff --git a/src/index.ts b/src/index.ts index 6d77e229..058ab5cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,4 @@ -import { HttpProxyMiddleware } from './http-proxy-middleware'; -import type { Options, RequestHandler, NextFunction } from './types'; -import type * as http from 'http'; - -export function createProxyMiddleware< - TReq = http.IncomingMessage, - TRes = http.ServerResponse, - TNext = NextFunction, ->(options: Options): RequestHandler { - const { middleware } = new HttpProxyMiddleware(options); - return middleware as unknown as RequestHandler; -} +export * from './factory'; export * from './handlers'; diff --git a/src/legacy/create-proxy-middleware.ts b/src/legacy/create-proxy-middleware.ts index 5dcb88f7..16fd4376 100644 --- a/src/legacy/create-proxy-middleware.ts +++ b/src/legacy/create-proxy-middleware.ts @@ -1,4 +1,4 @@ -import { createProxyMiddleware } from '..'; +import { createProxyMiddleware } from '../factory'; import { Debug } from '../debug'; import { Filter, RequestHandler } from '../types'; import { legacyOptionsAdapter } from './options-adapter'; diff --git a/src/legacy/options-adapter.ts b/src/legacy/options-adapter.ts index e1460ced..5022c440 100644 --- a/src/legacy/options-adapter.ts +++ b/src/legacy/options-adapter.ts @@ -1,5 +1,5 @@ import * as url from 'url'; -import { Filter, Options } from '..'; +import { Filter, Options } from '../types'; import { LegacyOptions } from './types'; import { Debug } from '../debug'; import { getLogger } from '../logger'; diff --git a/src/legacy/types.ts b/src/legacy/types.ts index 1e053ab3..4d442c1f 100644 --- a/src/legacy/types.ts +++ b/src/legacy/types.ts @@ -1,5 +1,5 @@ import type * as http from 'http'; -import { Options } from '..'; +import { Options } from '../types'; /** * @deprecated