Skip to content

Commit edf037c

Browse files
committed
WIP
1 parent 95ad90b commit edf037c

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

demos/ws-proxy.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const http = require('http')
2+
const WebSocket = require('faye-websocket')
3+
4+
const server = http.createServer()
5+
6+
server.on('upgrade', (request, socket, body) => {
7+
const client = new WebSocket(request, socket, body)
8+
const target = new WebSocket.Client('ws://ws.ifelse.io')
9+
10+
client.pipe(target)
11+
target.pipe(client)
12+
})
13+
14+
server.listen(3000)

index.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ declare namespace fastgateway {
2121
proxyType?: Type;
2222
proxyConfig?: {};
2323
proxyHandler?: Function;
24-
http2?: boolean;
2524
pathRegex?: string;
2625
timeout?: number;
2726
prefix: string;
@@ -33,6 +32,16 @@ declare namespace fastgateway {
3332
hooks?: Hooks;
3433
}
3534

35+
interface WebSocketRoute {
36+
proxyType: 'websocket';
37+
proxyConfig?: {};
38+
proxyHandler?: Function;
39+
prefix: string;
40+
prefixRewrite?: string;
41+
target: string;
42+
middlewares?: Function[];
43+
}
44+
3645
interface Hooks {
3746
onRequest?: Function,
3847
rewriteHeaders?: Function,
@@ -54,7 +63,7 @@ declare namespace fastgateway {
5463
pathRegex?: string;
5564
timeout?: number;
5665
targetOverride?: string;
57-
routes: Route[];
66+
routes: Route[] | WebSocketRoute[];
5867
}
5968
}
6069

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"express": "^4.17.1",
4949
"express-jwt": "^6.1.0",
5050
"express-rate-limit": "^5.5.1",
51+
"faye-websocket": "^0.11.4",
5152
"fg-multiple-hooks": "^1.3.0",
5253
"helmet": "^4.6.0",
5354
"http-lambda-proxy": "^1.1.4",

0 commit comments

Comments
 (0)