DefinitelyTyped/types/express-http-proxy/index.d.ts

69 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

// Type definitions for express-http-proxy 1.6
// 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>
// Niek van Bennekom <https://github.com/niekvb>
// John L. Singleton <https://github.com/jsinglet>
// Lindsay Wardell <https://github.com/lindsaykwardell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { RequestHandler, Request, Response, NextFunction } from "express";
2019-01-09 15:55:40 +00:00
import { RequestOptions, IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
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;
proxyErrorHandler?: (
err: any,
res: Response,
next: NextFunction
) => any;
proxyReqPathResolver?: (req: Request) => string | Promise<string>;
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>;
/**
* 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>;
skipToNextHandlerFilter?: (proxyRes: Response) => boolean;
proxyReqBodyDecorator?: (bodyContent: any, srcReq: Request) => any;
preserveHostHdr?: boolean;
parseReqBody?: boolean;
memoizeHost?: boolean;
https?: boolean;
reqAsBuffer?: boolean;
reqBodyEncoding?: string | null;
timeout?: number;
}
}
declare function proxy(
host: string | ((req: Request) => string),
options?: proxy.ProxyOptions
): RequestHandler;
export = proxy;