examples(with-sockets): create server inside export function (#6396)

This commit is contained in:
radimhornicek 2019-09-11 11:17:13 +02:00 committed by Pooya Parsa
parent 8e34632066
commit 0e0149d821

View File

@ -1,10 +1,10 @@
import http from 'http'
import socketIO from 'socket.io'
const server = http.createServer(this.nuxt.renderer.app)
const io = socketIO(server)
export default function () {
const server = http.createServer(this.nuxt.renderer.app)
const io = socketIO(server)
// overwrite nuxt.server.listen()
this.nuxt.server.listen = (port, host) => new Promise(resolve => server.listen(port || 3000, host || 'localhost', resolve))
// close this server on 'close' event