rethinkdb-websocket-server icon indicating copy to clipboard operation
rethinkdb-websocket-server copied to clipboard

Use with existing Express/port

Open GeoffreyPlitt opened this issue 8 years ago • 1 comments

I'd like to use this with an existing Express application that is already listening on a port.

Is it possible to do that, i.e. plug this in to a specific route on an existing web server, instead of listening on its own port?

GeoffreyPlitt avatar Sep 06 '16 17:09 GeoffreyPlitt

Yes, see the bottom of the "involved example" on the readme

var app = express();
app.use('/', express.static('assets'));
var httpServer = http.createServer(app);
options.httpServer = httpServer;
options.httpPath = '/rethinkApi';

RethinkdbWebsocketServer.listen(options);
httpServer.listen(8000);

As long as you run RethinkdbWebsocketServer.listen with the httpServer set to the server from your existing express application, it should work.

mikemintz avatar Sep 06 '16 18:09 mikemintz