🤖 Merge PR #44608 fix(express-http-proxy): correct filter method definition by @peterblazejewicz

This correct return type of the `filter` method to allow returning a
promise as per public documentation:

https://github.com/villadora/express-http-proxy#filter-supports-promises

/cc @ignaciocaff

Thanks!

Fixes #44550
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-05-10 08:55:06 +02:00 committed by GitHub
parent a2bc1d868d
commit 92168ee392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -106,6 +106,13 @@ proxy("www.google.com", {
return req.method === "GET";
}
});
proxy("www.google.com", {
filter: (req, res) => {
return new Promise(resolve => {
resolve(req.method === 'GET');
});
}
});
proxy("www.google.com", {
memoizeHost: true

View File

@ -43,7 +43,11 @@ declare namespace proxy {
userReq: Request,
userRes: Response
) => Buffer | string | Promise<Buffer | string>;
filter?: (req: Request, res: Response) => boolean;
/**
* 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;