Skip to content

chore(package): bump prettier to v3 #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ It was common to rewrite the `basePath` with the `pathRewrite` option:

```js
// before
app.use('/user', proxy({
target: 'http://www.example.org'
pathRewrite: { '^/user': '/secret' }
}));
app.use(
'/user',
proxy({
target: 'http://www.example.org',
pathRewrite: { '^/user': '/secret' },
}),
);

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

```js
// not affected
app.use(proxy({
target: 'http://www.example.org'
pathRewrite: { '^/user': '/secret' }
}));
app.use(
proxy({
target: 'http://www.example.org',
pathRewrite: { '^/user': '/secret' },
}),
);
```

### Removed "shorthand" usage
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.use(
createProxyMiddleware({
target: 'http://www.example.org/secret',
changeOrigin: true,
})
}),
);

app.listen(3000);
Expand All @@ -62,7 +62,7 @@ app.use(
createProxyMiddleware({
target: 'http://www.example.org/api',
changeOrigin: true,
})
}),
);

app.listen(3000);
Expand Down Expand Up @@ -165,7 +165,7 @@ app.use(
target: 'http://www.example.org/api',
changeOrigin: true,
pathFilter: '/api/proxy-only-this-path',
})
}),
);
```

Expand Down Expand Up @@ -490,7 +490,7 @@ The following options are provided by the underlying [http-proxy](https://github
target: 'http://127.0.0.1:4003/',
buffer: streamify(req.rawBody),
},
next
next,
);
};
```
Expand Down
2 changes: 1 addition & 1 deletion examples/websocket/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@
"browser-sync": "2.29.1",
"connect": "3.7.0",
"eslint": "8.39.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"express": "4.18.2",
"get-port": "5.1.1",
"husky": "8.0.3",
"jest": "29.5.0",
"lint-staged": "13.2.1",
"mockttp": "3.7.1",
"open": "8.4.2",
"prettier": "2.8.8",
"prettier": "3.0.3",
"supertest": "6.3.3",
"ts-jest": "29.1.0",
"typescript": "5.0.4",
Expand Down
6 changes: 5 additions & 1 deletion recipes/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ app.use('/api', createProxyMiddleware({ target: 'http://localhost:3000/api', cha

```javascript
app.use(
createProxyMiddleware({ target: 'http://localhost:3000', changeOrigin: true, pathFilter: '/api' })
createProxyMiddleware({
target: 'http://localhost:3000',
changeOrigin: true,
pathFilter: '/api',
}),
);
```
4 changes: 2 additions & 2 deletions recipes/servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ app.use(
createProxyMiddleware({
target: 'http://www.example.org',
changeOrigin: true,
})
}),
);

app.listen(3000);
Expand Down Expand Up @@ -345,7 +345,7 @@ gulp.task('webserver', function () {
directoryListing: true,
open: true,
middleware: [apiProxy],
})
}),
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/fix-request-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type BodyParserLikeRequest = http.IncomingMessage & { body: any };
*/
export function fixRequestBody<TReq = http.IncomingMessage>(
proxyReq: http.ClientRequest,
req: TReq
req: TReq,
): void {
const requestBody = (req as unknown as BodyParserLikeRequest).body;

Expand Down
8 changes: 4 additions & 4 deletions src/handlers/response-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (
buffer: Buffer,
proxyRes: TReq,
req: TReq,
res: TRes
res: TRes,
) => Promise<Buffer | string>;

/**
Expand All @@ -21,12 +21,12 @@ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (
*/
export function responseInterceptor<
TReq extends http.IncomingMessage = http.IncomingMessage,
TRes extends http.ServerResponse = http.ServerResponse
TRes extends http.ServerResponse = http.ServerResponse,
>(interceptor: Interceptor<TReq, TRes>) {
return async function proxyResResponseInterceptor(
proxyRes: TReq,
req: TReq,
res: TRes
res: TRes,
): Promise<void> {
debug('intercept proxy response');
const originalProxyRes = proxyRes;
Expand Down Expand Up @@ -67,7 +67,7 @@ export function responseInterceptor<
*/
function decompress<TReq extends http.IncomingMessage = http.IncomingMessage>(
proxyRes: TReq,
contentEncoding?: string
contentEncoding?: string,
): TReq | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress {
let _proxyRes: TReq | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress = proxyRes;
let decompress;
Expand Down
2 changes: 1 addition & 1 deletion src/http-proxy-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class HttpProxyMiddleware<TReq, TRes> {
*/
private shouldProxy = (
pathFilter: Filter<TReq> | undefined,
req: http.IncomingMessage
req: http.IncomingMessage,
): boolean => {
return matchPathFilter(pathFilter, req.url, req);
};
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type * as http from 'http';
export function createProxyMiddleware<
TReq = http.IncomingMessage,
TRes = http.ServerResponse,
TNext = NextFunction
TNext = NextFunction,
>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext> {
const { middleware } = new HttpProxyMiddleware<TReq, TRes>(options);
return middleware as unknown as RequestHandler<TReq, TRes, TNext>;
Expand Down
10 changes: 5 additions & 5 deletions src/legacy/create-proxy-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ const debug = Debug.extend('legacy-create-proxy-middleware');
*/
export function legacyCreateProxyMiddleware<
TReq = http.IncomingMessage,
TRes = http.ServerResponse
TRes = http.ServerResponse,
>(shortHand: string): RequestHandler<TReq, TRes>;
export function legacyCreateProxyMiddleware<
TReq = http.IncomingMessage,
TRes = http.ServerResponse
TRes = http.ServerResponse,
>(legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
export function legacyCreateProxyMiddleware<
TReq = http.IncomingMessage,
TRes = http.ServerResponse
TRes = http.ServerResponse,
>(
legacyContext: Filter<TReq>,
legacyOptions: LegacyOptions<TReq, TRes>
legacyOptions: LegacyOptions<TReq, TRes>,
): RequestHandler<TReq, TRes>;
export function legacyCreateProxyMiddleware<
TReq = http.IncomingMessage,
TRes = http.ServerResponse
TRes = http.ServerResponse,
>(legacyContext, legacyOptions?): RequestHandler<TReq, TRes> {
debug('init');

Expand Down
10 changes: 5 additions & 5 deletions src/legacy/options-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const proxyEventMap = {
*/
export function legacyOptionsAdapter<TReq, TRes>(
legacyContext: Filter<TReq> | LegacyOptions<TReq, TRes>,
legacyOptions: LegacyOptions<TReq, TRes>
legacyOptions: LegacyOptions<TReq, TRes>,
): Options<TReq, TRes> {
let options: LegacyOptions<TReq, TRes> = {};
let logger: Logger;
Expand All @@ -34,7 +34,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
Please use "legacyCreateProxyMiddleware({ target: 'http://www.example.org' })" instead.

More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-shorthand-usage
`
`,
);
}

Expand All @@ -53,7 +53,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
}

More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-context-argument
`
`,
);
} else if (legacyContext && !legacyOptions) {
options = { ...(legacyContext as LegacyOptions<TReq, TRes>) };
Expand All @@ -80,7 +80,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
}

More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#refactored-proxy-events
`
`,
);
}
});
Expand All @@ -103,7 +103,7 @@ export function legacyOptionsAdapter<TReq, TRes>(
}

More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-logprovider-and-loglevel-options
`
`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/path-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type * as http from 'http';
export function matchPathFilter<TReq = http.IncomingMessage>(
pathFilter: Filter<TReq> = '/',
uri: string | undefined,
req: http.IncomingMessage
req: http.IncomingMessage,
): boolean {
// single path
if (isStringPath(pathFilter as string)) {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type NextFunction<T = (err?: any) => void> = T;
export interface RequestHandler<
TReq = http.IncomingMessage,
TRes = http.ServerResponse,
TNext = NextFunction
TNext = NextFunction,
> {
(req: TReq, res: TRes, next?: TNext): void | Promise<void>;
upgrade: (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
Expand Down
Loading