2020-04-01 16:44:40 +00:00
|
|
|
// Type definitions for express-http-proxy 1.6
|
2018-12-21 15:21:39 +00:00
|
|
|
// Project: https://github.com/villadora/express-http-proxy#readme
|
2019-01-09 15:55:40 +00:00
|
|
|
// Definitions by: ulrichb <https://github.com/ulrichb>
|
|
|
|
|
// Daniel Schopf <https://github.com/Danscho>
|
2019-03-29 14:32:57 +00:00
|
|
|
// Gabriel Fournier <https://github.com/carboneater>
|
2019-05-03 21:46:25 +00:00
|
|
|
// Niek van Bennekom <https://github.com/niekvb>
|
2019-05-15 15:50:20 +00:00
|
|
|
// John L. Singleton <https://github.com/jsinglet>
|
2019-06-08 01:51:22 +00:00
|
|
|
// Lindsay Wardell <https://github.com/lindsaykwardell>
|
2018-12-21 15:21:39 +00:00
|
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
2019-08-19 00:47:36 +00:00
|
|
|
// TypeScript Version: 2.3
|
2018-12-21 15:21:39 +00:00
|
|
|
|
2019-05-04 00:03:01 +00:00
|
|
|
import { RequestHandler, Request, Response, NextFunction } from "express";
|
2019-01-09 15:55:40 +00:00
|
|
|
import { RequestOptions, IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
|
2018-12-21 15:21:39 +00:00
|
|
|
|
2019-05-15 15:50:20 +00:00
|
|
|
declare namespace proxy {
|
|
|
|
|
interface ProxyOptions {
|
|
|
|
|
/**
|
|
|
|
|
* The byte limit of the body. This is the number of bytes or any string
|
|
|
|
|
* format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`.
|
|
|
|
|
* See https://github.com/stream-utils/raw-body/blob/master/index.d.ts
|
|
|
|
|
*/
|
|
|
|
|
limit?: number | string;
|
2019-06-08 01:51:22 +00:00
|
|
|
proxyErrorHandler?: (
|
|
|
|
|
err: any,
|
|
|
|
|
res: Response,
|
|
|
|
|
next: NextFunction
|
|
|
|
|
) => any;
|
2020-04-01 16:44:40 +00:00
|
|
|
proxyReqPathResolver?: (req: Request) => string | Promise<string>;
|
2019-06-08 01:51:22 +00:00
|
|
|
proxyReqOptDecorator?: (
|
|
|
|
|
proxyReqOpts: RequestOptions,
|
|
|
|
|
srcReq: Request
|
|
|
|
|
) => RequestOptions | Promise<RequestOptions>;
|
|
|
|
|
userResHeaderDecorator?: (
|
|
|
|
|
headers: IncomingHttpHeaders,
|
|
|
|
|
userReq: Request,
|
|
|
|
|
userRes: Response,
|
|
|
|
|
proxyReq: Request,
|
|
|
|
|
proxyRes: Response
|
|
|
|
|
) => OutgoingHttpHeaders;
|
|
|
|
|
userResDecorator?: (
|
|
|
|
|
proxyRes: Response,
|
|
|
|
|
proxyResData: any,
|
|
|
|
|
userReq: Request,
|
|
|
|
|
userRes: Response
|
|
|
|
|
) => Buffer | string | Promise<Buffer | string>;
|
2020-05-10 06:55:06 +00:00
|
|
|
/**
|
|
|
|
|
* The filter option can be used to limit what requests are proxied.
|
|
|
|
|
* Return true to continue to execute proxy; return false-y to skip proxy for this request.
|
|
|
|
|
*/
|
|
|
|
|
filter?: (req: Request, res: Response) => boolean | Promise<boolean>;
|
2019-07-01 18:08:27 +00:00
|
|
|
skipToNextHandlerFilter?: (proxyRes: Response) => boolean;
|
|
|
|
|
proxyReqBodyDecorator?: (bodyContent: any, srcReq: Request) => any;
|
2019-05-15 15:50:20 +00:00
|
|
|
preserveHostHdr?: boolean;
|
|
|
|
|
parseReqBody?: boolean;
|
2019-06-08 01:51:22 +00:00
|
|
|
memoizeHost?: boolean;
|
|
|
|
|
https?: boolean;
|
|
|
|
|
reqAsBuffer?: boolean;
|
|
|
|
|
reqBodyEncoding?: string | null;
|
|
|
|
|
timeout?: number;
|
2019-05-15 15:50:20 +00:00
|
|
|
}
|
2018-12-21 15:21:39 +00:00
|
|
|
}
|
|
|
|
|
|
2019-06-08 01:51:22 +00:00
|
|
|
declare function proxy(
|
|
|
|
|
host: string | ((req: Request) => string),
|
|
|
|
|
options?: proxy.ProxyOptions
|
|
|
|
|
): RequestHandler;
|
2018-12-21 15:21:39 +00:00
|
|
|
|
2018-12-21 18:26:12 +00:00
|
|
|
export = proxy;
|