Skip to content

Commit 5b10650

Browse files
authored
chore(package): bump prettier to v3 (#934)
1 parent d7aa01d commit 5b10650

22 files changed

+254
-112
lines changed

MIGRATION.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ It was common to rewrite the `basePath` with the `pathRewrite` option:
6464

6565
```js
6666
// before
67-
app.use('/user', proxy({
68-
target: 'http://www.example.org'
69-
pathRewrite: { '^/user': '/secret' }
70-
}));
67+
app.use(
68+
'/user',
69+
proxy({
70+
target: 'http://www.example.org',
71+
pathRewrite: { '^/user': '/secret' },
72+
}),
73+
);
7174

7275
// after
7376
app.use('/user', proxy({ target: 'http://www.example.org/secret' }));
@@ -77,10 +80,12 @@ When proxy is mounted at the root, `pathRewrite` should still work as in v2.
7780

7881
```js
7982
// not affected
80-
app.use(proxy({
81-
target: 'http://www.example.org'
82-
pathRewrite: { '^/user': '/secret' }
83-
}));
83+
app.use(
84+
proxy({
85+
target: 'http://www.example.org',
86+
pathRewrite: { '^/user': '/secret' },
87+
}),
88+
);
8489
```
8590

8691
### Removed "shorthand" usage

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.use(
4040
createProxyMiddleware({
4141
target: 'http://www.example.org/secret',
4242
changeOrigin: true,
43-
})
43+
}),
4444
);
4545

4646
app.listen(3000);
@@ -62,7 +62,7 @@ app.use(
6262
createProxyMiddleware({
6363
target: 'http://www.example.org/api',
6464
changeOrigin: true,
65-
})
65+
}),
6666
);
6767

6868
app.listen(3000);
@@ -165,7 +165,7 @@ app.use(
165165
target: 'http://www.example.org/api',
166166
changeOrigin: true,
167167
pathFilter: '/api/proxy-only-this-path',
168-
})
168+
}),
169169
);
170170
```
171171

@@ -490,7 +490,7 @@ The following options are provided by the underlying [http-proxy](https://github
490490
target: 'http://127.0.0.1:4003/',
491491
buffer: streamify(req.rawBody),
492492
},
493-
next
493+
next,
494494
);
495495
};
496496
```

examples/websocket/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@
6767
"browser-sync": "2.29.1",
6868
"connect": "3.7.0",
6969
"eslint": "8.39.0",
70-
"eslint-config-prettier": "8.8.0",
71-
"eslint-plugin-prettier": "4.2.1",
70+
"eslint-config-prettier": "9.0.0",
71+
"eslint-plugin-prettier": "5.0.0",
7272
"express": "4.18.2",
7373
"get-port": "5.1.1",
7474
"husky": "8.0.3",
7575
"jest": "29.5.0",
7676
"lint-staged": "13.2.1",
7777
"mockttp": "3.7.1",
7878
"open": "8.4.2",
79-
"prettier": "2.8.8",
79+
"prettier": "3.0.3",
8080
"supertest": "6.3.3",
8181
"ts-jest": "29.1.0",
8282
"typescript": "5.0.4",

recipes/basic.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ app.use('/api', createProxyMiddleware({ target: 'http://localhost:3000/api', cha
1919

2020
```javascript
2121
app.use(
22-
createProxyMiddleware({ target: 'http://localhost:3000', changeOrigin: true, pathFilter: '/api' })
22+
createProxyMiddleware({
23+
target: 'http://localhost:3000',
24+
changeOrigin: true,
25+
pathFilter: '/api',
26+
}),
2327
);
2428
```

recipes/servers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ app.use(
170170
createProxyMiddleware({
171171
target: 'http://www.example.org',
172172
changeOrigin: true,
173-
})
173+
}),
174174
);
175175

176176
app.listen(3000);
@@ -345,7 +345,7 @@ gulp.task('webserver', function () {
345345
directoryListing: true,
346346
open: true,
347347
middleware: [apiProxy],
348-
})
348+
}),
349349
);
350350
});
351351

src/handlers/fix-request-body.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type BodyParserLikeRequest = http.IncomingMessage & { body: any };
88
*/
99
export function fixRequestBody<TReq = http.IncomingMessage>(
1010
proxyReq: http.ClientRequest,
11-
req: TReq
11+
req: TReq,
1212
): void {
1313
const requestBody = (req as unknown as BodyParserLikeRequest).body;
1414

src/handlers/response-interceptor.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (
99
buffer: Buffer,
1010
proxyRes: TReq,
1111
req: TReq,
12-
res: TRes
12+
res: TRes,
1313
) => Promise<Buffer | string>;
1414

1515
/**
@@ -21,12 +21,12 @@ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (
2121
*/
2222
export function responseInterceptor<
2323
TReq extends http.IncomingMessage = http.IncomingMessage,
24-
TRes extends http.ServerResponse = http.ServerResponse
24+
TRes extends http.ServerResponse = http.ServerResponse,
2525
>(interceptor: Interceptor<TReq, TRes>) {
2626
return async function proxyResResponseInterceptor(
2727
proxyRes: TReq,
2828
req: TReq,
29-
res: TRes
29+
res: TRes,
3030
): Promise<void> {
3131
debug('intercept proxy response');
3232
const originalProxyRes = proxyRes;
@@ -67,7 +67,7 @@ export function responseInterceptor<
6767
*/
6868
function decompress<TReq extends http.IncomingMessage = http.IncomingMessage>(
6969
proxyRes: TReq,
70-
contentEncoding?: string
70+
contentEncoding?: string,
7171
): TReq | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress {
7272
let _proxyRes: TReq | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress = proxyRes;
7373
let decompress;

src/http-proxy-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class HttpProxyMiddleware<TReq, TRes> {
107107
*/
108108
private shouldProxy = (
109109
pathFilter: Filter<TReq> | undefined,
110-
req: http.IncomingMessage
110+
req: http.IncomingMessage,
111111
): boolean => {
112112
return matchPathFilter(pathFilter, req.url, req);
113113
};

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type * as http from 'http';
55
export function createProxyMiddleware<
66
TReq = http.IncomingMessage,
77
TRes = http.ServerResponse,
8-
TNext = NextFunction
8+
TNext = NextFunction,
99
>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext> {
1010
const { middleware } = new HttpProxyMiddleware<TReq, TRes>(options);
1111
return middleware as unknown as RequestHandler<TReq, TRes, TNext>;

src/legacy/create-proxy-middleware.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ const debug = Debug.extend('legacy-create-proxy-middleware');
1515
*/
1616
export function legacyCreateProxyMiddleware<
1717
TReq = http.IncomingMessage,
18-
TRes = http.ServerResponse
18+
TRes = http.ServerResponse,
1919
>(shortHand: string): RequestHandler<TReq, TRes>;
2020
export function legacyCreateProxyMiddleware<
2121
TReq = http.IncomingMessage,
22-
TRes = http.ServerResponse
22+
TRes = http.ServerResponse,
2323
>(legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
2424
export function legacyCreateProxyMiddleware<
2525
TReq = http.IncomingMessage,
26-
TRes = http.ServerResponse
26+
TRes = http.ServerResponse,
2727
>(
2828
legacyContext: Filter<TReq>,
29-
legacyOptions: LegacyOptions<TReq, TRes>
29+
legacyOptions: LegacyOptions<TReq, TRes>,
3030
): RequestHandler<TReq, TRes>;
3131
export function legacyCreateProxyMiddleware<
3232
TReq = http.IncomingMessage,
33-
TRes = http.ServerResponse
33+
TRes = http.ServerResponse,
3434
>(legacyContext, legacyOptions?): RequestHandler<TReq, TRes> {
3535
debug('init');
3636

src/legacy/options-adapter.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const proxyEventMap = {
2222
*/
2323
export function legacyOptionsAdapter<TReq, TRes>(
2424
legacyContext: Filter<TReq> | LegacyOptions<TReq, TRes>,
25-
legacyOptions: LegacyOptions<TReq, TRes>
25+
legacyOptions: LegacyOptions<TReq, TRes>,
2626
): Options<TReq, TRes> {
2727
let options: LegacyOptions<TReq, TRes> = {};
2828
let logger: Logger;
@@ -34,7 +34,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
3434
Please use "legacyCreateProxyMiddleware({ target: 'http://www.example.org' })" instead.
3535
3636
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-shorthand-usage
37-
`
37+
`,
3838
);
3939
}
4040

@@ -53,7 +53,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
5353
}
5454
5555
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-context-argument
56-
`
56+
`,
5757
);
5858
} else if (legacyContext && !legacyOptions) {
5959
options = { ...(legacyContext as LegacyOptions<TReq, TRes>) };
@@ -80,7 +80,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
8080
}
8181
8282
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#refactored-proxy-events
83-
`
83+
`,
8484
);
8585
}
8686
});
@@ -103,7 +103,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
103103
}
104104
105105
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-logprovider-and-loglevel-options
106-
`
106+
`,
107107
);
108108
}
109109

src/path-filter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type * as http from 'http';
88
export function matchPathFilter<TReq = http.IncomingMessage>(
99
pathFilter: Filter<TReq> = '/',
1010
uri: string | undefined,
11-
req: http.IncomingMessage
11+
req: http.IncomingMessage,
1212
): boolean {
1313
// single path
1414
if (isStringPath(pathFilter as string)) {

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type NextFunction<T = (err?: any) => void> = T;
1414
export interface RequestHandler<
1515
TReq = http.IncomingMessage,
1616
TRes = http.ServerResponse,
17-
TNext = NextFunction
17+
TNext = NextFunction,
1818
> {
1919
(req: TReq, res: TRes, next?: TNext): void | Promise<void>;
2020
upgrade: (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;

0 commit comments

Comments
 (0)