Skip to content

Commit 677cddb

Browse files
authored
docs: improve jsdoc for http-proxy options (#889)
1 parent baae2a0 commit 677cddb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/types.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,22 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
4949
* Narrow down requests to proxy or not.
5050
* Filter on {@link http.IncomingMessage.url `pathname`} which is relative to the proxy's "mounting" point in the server.
5151
* Or use the {@link http.IncomingMessage `req`} object for more complex filtering.
52+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathFilter.md
53+
* @since v3.0.0
5254
*/
5355
pathFilter?: Filter<TReq>;
56+
/**
57+
* Modify request paths before requests are send to the target.
58+
* @example
59+
* ```js
60+
* createProxyMiddleware({
61+
* pathRewrite: {
62+
* '^/api/old-path': '/api/new-path', // rewrite path
63+
* }
64+
* });
65+
* ```
66+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
67+
*/
5468
pathRewrite?:
5569
| { [regexp: string]: string }
5670
| ((path: string, req: TReq) => string)
@@ -68,12 +82,15 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
6882
* }]
6983
* });
7084
* ```
85+
* @link https://github.com/chimurai/http-proxy-middleware#plugins-array
86+
* @since v3.0.0
7187
*/
7288
plugins?: Plugin<TReq, TRes>[];
7389
/**
7490
* Eject pre-configured plugins.
7591
* NOTE: register your own error handlers to prevent server from crashing.
7692
*
93+
* @link https://github.com/chimurai/http-proxy-middleware#ejectplugins-boolean-default-false
7794
* @since v3.0.0
7895
*/
7996
ejectPlugins?: boolean;
@@ -90,8 +107,22 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
90107
* }
91108
* });
92109
* ```
110+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md
111+
* @since v3.0.0
93112
*/
94113
on?: OnProxyEvent<TReq, TRes>;
114+
/**
115+
* Dynamically set the {@link Options.target `options.target`}.
116+
* @example
117+
* ```js
118+
* createProxyMiddleware({
119+
* router: async (req) => {
120+
* return 'http://127:0.0.1:3000';
121+
* }
122+
* });
123+
* ```
124+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
125+
*/
95126
router?:
96127
| { [hostOrPath: string]: httpProxy.ServerOptions['target'] }
97128
| ((req: TReq) => httpProxy.ServerOptions['target'])
@@ -104,6 +135,8 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
104135
* logger: console
105136
* });
106137
* ```
138+
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
139+
* @since v3.0.0
107140
*/
108141
logger?: Logger | any;
109142
}

0 commit comments

Comments
 (0)