Skip to content

Commit b36cd95

Browse files
authored
Merge branch 'master' into master
2 parents 4934230 + f999d1c commit b36cd95

File tree

5 files changed

+1009
-844
lines changed

5 files changed

+1009
-844
lines changed

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,35 @@
5151
},
5252
"homepage": "https://github.com/chimurai/http-proxy-middleware#readme",
5353
"devDependencies": {
54-
"@commitlint/cli": "^12.1.4",
55-
"@commitlint/config-conventional": "^12.1.4",
56-
"@types/express": "4.17.7",
57-
"@types/is-glob": "^4.0.1",
58-
"@types/jest": "^26.0.23",
59-
"@types/micromatch": "^4.0.1",
60-
"@types/node": "^15.6.2",
54+
"@commitlint/cli": "^13.1.0",
55+
"@commitlint/config-conventional": "^13.1.0",
56+
"@types/express": "^4.17.13",
57+
"@types/is-glob": "^4.0.2",
58+
"@types/jest": "^27.0.1",
59+
"@types/micromatch": "^4.0.2",
60+
"@types/node": "^16.6.1",
6161
"@types/supertest": "^2.0.11",
62-
"@types/ws": "^7.4.4",
63-
"@typescript-eslint/eslint-plugin": "^4.26.0",
64-
"@typescript-eslint/parser": "^4.26.0",
62+
"@types/ws": "^7.4.7",
63+
"@typescript-eslint/eslint-plugin": "^4.29.1",
64+
"@typescript-eslint/parser": "^4.29.1",
6565
"body-parser": "^1.19.0",
66-
"browser-sync": "^2.26.14",
66+
"browser-sync": "^2.27.5",
6767
"connect": "^3.7.0",
68-
"eslint": "^7.27.0",
68+
"eslint": "^7.32.0",
6969
"eslint-config-prettier": "^8.3.0",
7070
"eslint-plugin-prettier": "^3.4.0",
7171
"express": "^4.17.1",
7272
"get-port": "^5.1.1",
73-
"husky": "^6.0.0",
74-
"jest": "^27.0.3",
75-
"lint-staged": "^11.0.0",
76-
"mockttp": "^1.2.2",
77-
"open": "^8.2.0",
78-
"prettier": "^2.3.0",
79-
"supertest": "^6.1.3",
80-
"ts-jest": "^27.0.2",
81-
"typescript": "^4.3.2",
82-
"ws": "^7.4.6"
73+
"husky": "^7.0.1",
74+
"jest": "^27.0.6",
75+
"lint-staged": "^11.1.2",
76+
"mockttp": "^2.2.2",
77+
"open": "^8.2.1",
78+
"prettier": "^2.3.2",
79+
"supertest": "^6.1.5",
80+
"ts-jest": "^27.0.4",
81+
"typescript": "^4.3.5",
82+
"ws": "^8.1.0"
8383
},
8484
"dependencies": {
8585
"@types/http-proxy": "^1.17.6",

src/_handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function defaultErrorHandler(err, req: express.Request, res: express.Response) {
7979
}
8080
}
8181

82-
res.end(`Error occured while trying to proxy: ${host}${req.url}`);
82+
res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
8383
}
8484

8585
function logClose(req, socket, head) {

test/e2e/websocket.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('E2E WebSocket proxy', () => {
2525
wss = new WebSocketServer({ port: WS_SERVER_PORT });
2626

2727
wss.on('connection', (websocket) => {
28-
websocket.on('message', (message) => {
28+
websocket.on('message', (data, isBinary) => {
29+
const message = isBinary ? data : data.toString();
2930
websocket.send(message); // echo received message
3031
});
3132
});
@@ -66,7 +67,8 @@ describe('E2E WebSocket proxy', () => {
6667
});
6768

6869
it('should proxy to path', (done) => {
69-
ws.on('message', (message) => {
70+
ws.on('message', (data, isBinary) => {
71+
const message = isBinary ? data : data.toString();
7072
expect(message).toBe('foobar');
7173
done();
7274
});
@@ -84,7 +86,8 @@ describe('E2E WebSocket proxy', () => {
8486
});
8587

8688
it('should proxy to path', (done) => {
87-
ws.on('message', (message) => {
89+
ws.on('message', (data, isBinary) => {
90+
const message = isBinary ? data : data.toString();
8891
expect(message).toBe('foobar');
8992
done();
9093
});
@@ -109,7 +112,8 @@ describe('E2E WebSocket proxy', () => {
109112
});
110113

111114
it('should proxy to path', (done) => {
112-
ws.on('message', (message) => {
115+
ws.on('message', (data, isBinary) => {
116+
const message = isBinary ? data : data.toString();
113117
expect(message).toBe('foobar');
114118
done();
115119
});
@@ -136,7 +140,8 @@ describe('E2E WebSocket proxy', () => {
136140
});
137141

138142
it('should proxy to path', (done) => {
139-
ws.on('message', (message) => {
143+
ws.on('message', (data, isBinary) => {
144+
const message = isBinary ? data : data.toString();
140145
expect(message).toBe('foobar');
141146
done();
142147
});

test/unit/handlers.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('default proxy error handler', () => {
119119

120120
it('should end the response and return error message', () => {
121121
proxyError(mockError, mockReq, mockRes, proxyOptions);
122-
expect(errorMessage).toBe('Error occured while trying to proxy: localhost:3000/api');
122+
expect(errorMessage).toBe('Error occurred while trying to proxy: localhost:3000/api');
123123
});
124124

125125
it('should not set the http status code to: 500 if headers have already been sent', () => {
@@ -131,7 +131,7 @@ describe('default proxy error handler', () => {
131131
it('should end the response and return error message', () => {
132132
mockRes.headersSent = true;
133133
proxyError(mockError, mockReq, mockRes, proxyOptions);
134-
expect(errorMessage).toBe('Error occured while trying to proxy: localhost:3000/api');
134+
expect(errorMessage).toBe('Error occurred while trying to proxy: localhost:3000/api');
135135
});
136136

137137
it('should re-throw error from http-proxy when target is missing', () => {

0 commit comments

Comments
 (0)