From the docs I can see the subscriptionServer takes the standard node http node server.
I'd like to use a koa 2 server instead. Is that possible?
@myyellowshoe I don't actually know. Maybe you can try it and let us know? 馃檪
I'm not too familiar with koa but you might be able to do something like this to get the node http server:
const app = require('koa')();
const http = require('http');
app.use(...);
var server = http.createServer(app.callback());
server.listen(8080);
and pass http into the subscriptionServer.
It would be great to add this setup to the documentation. Hapi uses a similar pattern.
With koa2, this works fine :
const app = new Koa();
app.use(...);
const server = app.listen(8080);
new SubscriptionServer({
subscriptionManager,
...
}, {
path: '/subscriptions',
server,
});
Note the heading / in the path. Could not get it to work without it.
Cool I'll have to try it out. If I get it to work. Happy to help get this into the docs.
Should work now (since we allow any server to pass to WebSocket.Server instance).
@Urigo Great to know. @kouak Worked like a charm.
Most helpful comment
With koa2, this works fine :
Note the heading
/in the path. Could not get it to work without it.