Skip to content

Commit 5e79b93

Browse files
authored
chore(prettier): use prettier2 (#418)
1 parent e767654 commit 5e79b93

39 files changed

+222
-237
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ const options = {
132132
ws: true, // proxy websockets
133133
pathRewrite: {
134134
'^/api/old-path': '/api/new-path', // rewrite path
135-
'^/api/remove/path': '/path' // remove base path
135+
'^/api/remove/path': '/path', // remove base path
136136
},
137137
router: {
138138
// when request.headers.host == 'dev.localhost:3000',
139139
// override target 'http://www.example.org' to 'http://localhost:8000'
140-
'dev.localhost:3000': 'http://localhost:8000'
141-
}
140+
'dev.localhost:3000': 'http://localhost:8000',
141+
},
142142
};
143143

144144
// create the proxy (without context)
@@ -194,12 +194,12 @@ Providing an alternative way to decide which requests should be proxied; In case
194194
/**
195195
* @return {Boolean}
196196
*/
197-
const filter = function(pathname, req) {
197+
const filter = function (pathname, req) {
198198
return pathname.match('^/api') && req.method === 'GET';
199199
};
200200

201201
const apiProxy = createProxyMiddleware(filter, {
202-
target: 'http://www.example.org'
202+
target: 'http://www.example.org',
203203
});
204204
```
205205

@@ -285,7 +285,7 @@ Providing an alternative way to decide which requests should be proxied; In case
285285
debug: logger.debug,
286286
info: logger.info,
287287
warn: logger.warn,
288-
error: logger.error
288+
error: logger.error,
289289
};
290290
return myCustomProvider;
291291
}
@@ -300,7 +300,7 @@ Subscribe to [http-proxy events](https://github.com/nodejitsu/node-http-proxy#li
300300
```javascript
301301
function onError(err, req, res) {
302302
res.writeHead(500, {
303-
'Content-Type': 'text/plain'
303+
'Content-Type': 'text/plain',
304304
});
305305
res.end('Something went wrong. And we are reporting a custom error message.');
306306
}
@@ -417,7 +417,7 @@ The following options are provided by the underlying [http-proxy](https://github
417417
res,
418418
{
419419
target: 'http://localhost:4003/',
420-
buffer: streamify(req.rawBody)
420+
buffer: streamify(req.rawBody),
421421
},
422422
next
423423
);

examples/browser-sync/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { createProxyMiddleware } = require('../../dist'); // require('http-proxy-
1010
const jsonPlaceholderProxy = createProxyMiddleware('/users', {
1111
target: 'http://jsonplaceholder.typicode.com',
1212
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
13-
logLevel: 'debug'
13+
logLevel: 'debug',
1414
});
1515

1616
/**
@@ -20,9 +20,9 @@ browserSync.init({
2020
server: {
2121
baseDir: './',
2222
port: 3000,
23-
middleware: [jsonPlaceholderProxy]
23+
middleware: [jsonPlaceholderProxy],
2424
},
25-
startPath: '/users'
25+
startPath: '/users',
2626
});
2727

2828
console.log('[DEMO] Server: listening on port 3000');

examples/connect/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { createProxyMiddleware } = require('../../dist'); // require('http-proxy-
1111
const jsonPlaceholderProxy = createProxyMiddleware({
1212
target: 'http://jsonplaceholder.typicode.com',
1313
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
14-
logLevel: 'debug'
14+
logLevel: 'debug',
1515
});
1616

1717
const app = connect();

examples/express/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { createProxyMiddleware } = require('../../dist'); // require('http-proxy-
1010
const jsonPlaceholderProxy = createProxyMiddleware({
1111
target: 'http://jsonplaceholder.typicode.com',
1212
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
13-
logLevel: 'debug'
13+
logLevel: 'debug',
1414
});
1515

1616
const app = express();

examples/websocket/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const wsProxy = createProxyMiddleware('/', {
1515
// },
1616
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
1717
ws: true, // enable websocket proxy
18-
logLevel: 'debug'
18+
logLevel: 'debug',
1919
});
2020

2121
const app = express();

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
preset: 'ts-jest',
3-
testEnvironment: 'node'
3+
testEnvironment: 'node',
44
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"lint-staged": "^10.0.7",
6969
"mockttp": "^0.19.3",
7070
"open": "^7.0.2",
71-
"prettier": "^1.19.1",
71+
"prettier": "^2.0.2",
7272
"supertest": "^4.0.2",
7373
"ts-jest": "^25.2.0",
7474
"tslint": "^6.0.0",

recipes/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ const options = {
3232

3333
// additional request headers
3434
headers: {
35-
'x-powered-by': 'foobar'
35+
'x-powered-by': 'foobar',
3636
},
3737

3838
// rewrite paths
3939
pathRewrite: {
4040
'^/api/old-path': '/api/new-path', // rewrite path
41-
'^/api/remove/path': '/path' // remove base path
41+
'^/api/remove/path': '/path', // remove base path
4242
},
4343

4444
// re-target based on the request's host header and/or path
@@ -48,15 +48,15 @@ const options = {
4848
'integration.localhost:8000': 'http://localhost:8001', // host only
4949
'staging.localhost:8000': 'http://localhost:8002', // host only
5050
'localhost:8000/api': 'http://localhost:8003', // host + path
51-
'/rest': 'http://localhost:8004' // path only
51+
'/rest': 'http://localhost:8004', // path only
5252
},
5353

5454
// control logging
5555
logLevel: 'silent',
5656

5757
// use a different lib for logging;
5858
// i.e., write logs to file or server
59-
logProvider: function(provider) {
59+
logProvider: function (provider) {
6060
return winston;
6161
},
6262

@@ -67,16 +67,16 @@ const options = {
6767
},
6868

6969
// subscribe to http-proxy's proxyRes event
70-
onProxyRes: function(proxyRes, req, res) {
70+
onProxyRes: function (proxyRes, req, res) {
7171
proxyRes.headers['x-added'] = 'foobar';
7272
delete proxyRes.headers['x-removed'];
7373
},
7474

7575
// subscribe to http-proxy's proxyReq event
76-
onProxyReq: function(proxyReq, req, res) {
76+
onProxyReq: function (proxyReq, req, res) {
7777
// add custom header to request
7878
proxyReq.setHeader('x-powered-by', 'foobar');
79-
}
79+
},
8080

8181
/**
8282
* The following options are provided by Nodejitsu's http-proxy

recipes/context-matching.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This will match paths starting with `/api`
3434
const { createProxyMiddleware } = require('http-proxy-middleware');
3535

3636
const apiProxy = createProxyMiddleware('/api', {
37-
target: 'http://localhost:3000'
37+
target: 'http://localhost:3000',
3838
});
3939

4040
// `/api/foo/bar` -> `http://localhost:3000/api/foo/bar`
@@ -61,7 +61,7 @@ This will match paths starting with `/api/` and should also end with `.json`
6161
const { createProxyMiddleware } = require('http-proxy-middleware');
6262

6363
const apiProxy = createProxyMiddleware('/api/**/*.json', {
64-
target: 'http://localhost:3000'
64+
target: 'http://localhost:3000',
6565
});
6666
```
6767

@@ -73,7 +73,7 @@ Multiple wildcards can be used.
7373
const { createProxyMiddleware } = require('http-proxy-middleware');
7474

7575
const apiProxy = createProxyMiddleware(['/api/**/*.json', '/rest/**'], {
76-
target: 'http://localhost:3000'
76+
target: 'http://localhost:3000',
7777
});
7878
```
7979

@@ -85,7 +85,7 @@ This example will create a proxy with wildcard context matching.
8585
const { createProxyMiddleware } = require('http-proxy-middleware');
8686

8787
const apiProxy = createProxyMiddleware(['foo/*.js', '!bar.js'], {
88-
target: 'http://localhost:3000'
88+
target: 'http://localhost:3000',
8989
});
9090
```
9191

@@ -97,7 +97,7 @@ The request `pathname` and `req` object are provided to determine which requests
9797
```javascript
9898
const { createProxyMiddleware } = require('http-proxy-middleware');
9999

100-
const filter = function(pathname, req) {
100+
const filter = function (pathname, req) {
101101
return pathname.match('^/api') && req.method === 'GET';
102102
};
103103

recipes/corporate-proxy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const proxyServer = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
1313

1414
const options = {
1515
target: 'http://localhost:3000',
16-
agent: new HttpsProxyAgent(proxyServer)
16+
agent: new HttpsProxyAgent(proxyServer),
1717
};
1818

1919
const apiProxy = createProxyMiddleware('/api', options);

0 commit comments

Comments
 (0)