From 880a95c64704764e91871ebd364f2b4e4abb8ce8 Mon Sep 17 00:00:00 2001 From: Erik Beuschau <32451595+erik-beus@users.noreply.github.com> Date: Tue, 30 Apr 2019 01:49:43 +0200 Subject: [PATCH] express-http-proxy: Add limit parameter for proxy options (#35014) * Add limit parameter for proxy options * Remove null from type for limit --- types/express-http-proxy/express-http-proxy-tests.ts | 8 ++++++++ types/express-http-proxy/index.d.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/types/express-http-proxy/express-http-proxy-tests.ts b/types/express-http-proxy/express-http-proxy-tests.ts index c96ec0fc8d..6c628b3c49 100644 --- a/types/express-http-proxy/express-http-proxy-tests.ts +++ b/types/express-http-proxy/express-http-proxy-tests.ts @@ -11,6 +11,14 @@ proxy('www.google.com', { proxyReqPathResolver: (req) => req.url, }); +proxy('www.google.com', { + limit: "10mb" +}); + +proxy('www.google.com', { + limit: 1024 +}); + proxy('www.google.com', { proxyReqOptDecorator(proxyReqOpts, srcReq) { console.log(proxyReqOpts.headers, proxyReqOpts.method); diff --git a/types/express-http-proxy/index.d.ts b/types/express-http-proxy/index.d.ts index d1935f3bc3..6d1943fa9c 100644 --- a/types/express-http-proxy/index.d.ts +++ b/types/express-http-proxy/index.d.ts @@ -11,6 +11,12 @@ import { RequestOptions, IncomingHttpHeaders, OutgoingHttpHeaders } from "http"; import { Response } from "express-serve-static-core"; 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; proxyReqPathResolver?: (req: Request) => string; proxyReqOptDecorator?: (proxyReqOpts: RequestOptions, srcReq: Request) => RequestOptions; userResHeaderDecorator?: (headers: IncomingHttpHeaders, userReq: Request, userRes: Response, proxyReq: Request, proxyRes: Response) => OutgoingHttpHeaders;