File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,19 @@ const gateway = (opts) => {
35
35
} )
36
36
37
37
// processing websocket routes
38
- registerWebSocketRoutes ( {
39
- routes : opts . routes . filter ( route => route . proxyType === 'websocket' ) ,
40
- server : router . getServer ( )
41
- } )
38
+ const wsRoutes = opts . routes . filter ( route => route . proxyType === 'websocket' )
39
+ if ( wsRoutes . length ) {
40
+ if ( typeof router . getServer !== 'function' ) {
41
+ throw new Error (
42
+ 'Unable to retrieve the HTTP server instance. ' +
43
+ 'If you are not using restana, make sure to provide an "app.getServer()" alternative method!'
44
+ )
45
+ }
46
+ registerWebSocketRoutes ( {
47
+ routes : wsRoutes ,
48
+ server : router . getServer ( )
49
+ } )
50
+ }
42
51
43
52
// processing non-websocket routes
44
53
opts . routes . filter ( route => route . proxyType !== 'websocket' ) . forEach ( route => {
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const WebSocket = require ( 'faye-websocket' )
4
3
const { onOpenNoOp } = require ( './default-hooks' ) . websocket
5
4
6
5
module . exports = ( config ) => {
6
+ const WebSocket = require ( 'faye-websocket' )
7
+
7
8
const { routes, server } = config
8
9
9
10
const prefix2route = new Map ( )
You can’t perform that action at this time.
0 commit comments