mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 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:
parent
a2bc1d868d
commit
92168ee392
@ -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
|
||||
|
||||
6
types/express-http-proxy/index.d.ts
vendored
6
types/express-http-proxy/index.d.ts
vendored
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user