mikemintz/rethinkdb-websocket-server

Use with existing Express/port

Opened this issue · 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?

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.