mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Included definition for proxyErrorHandler in express-http-proxy (#35185)
This commit is contained in:
committed by
Wesley Wigham
parent
18b13d1f4a
commit
6a3064cc74
@@ -19,6 +19,16 @@ proxy('www.google.com', {
|
||||
limit: 1024
|
||||
});
|
||||
|
||||
proxy('www.google.com', {
|
||||
proxyErrorHandler: (err, res, next) => {
|
||||
switch (err && err.code) {
|
||||
case 'ECONNRESET': { return res.status(405).send('504 became 405'); }
|
||||
case 'ECONNREFUSED': { return res.status(200).send('gotcher back'); }
|
||||
default: { next(err); }
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
proxy('www.google.com', {
|
||||
proxyReqOptDecorator(proxyReqOpts, srcReq) {
|
||||
console.log(proxyReqOpts.headers, proxyReqOpts.method);
|
||||
|
||||
Vendored
+3
-1
@@ -3,12 +3,13 @@
|
||||
// Definitions by: ulrichb <https://github.com/ulrichb>
|
||||
// Daniel Schopf <https://github.com/Danscho>
|
||||
// Gabriel Fournier <https://github.com/carboneater>
|
||||
// Niek van Bennekom <https://github.com/niekvb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { RequestHandler, Request } from "express";
|
||||
import { RequestOptions, IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
|
||||
import { Response } from "express-serve-static-core";
|
||||
import { NextFunction, Response } from "express-serve-static-core";
|
||||
|
||||
interface ProxyOptions {
|
||||
/**
|
||||
@@ -17,6 +18,7 @@ interface ProxyOptions {
|
||||
* 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;
|
||||
proxyReqOptDecorator?: (proxyReqOpts: RequestOptions, srcReq: Request) => RequestOptions;
|
||||
userResHeaderDecorator?: (headers: IncomingHttpHeaders, userReq: Request, userRes: Response, proxyReq: Request, proxyRes: Response) => OutgoingHttpHeaders;
|
||||
|
||||
Reference in New Issue
Block a user