title: Where do I add this websocket code in the new nuxt.js setup since it does not have server?
body: <ul>
  <li>I am using the new version of Nuxt which does not come with a server folder</li>
  <li>In the old version, you had a server folder and an index.js which contained the app</li>
  <li>I want to add the websocket WS library with the new version of NuxtJS</li>
  </ul>
  <p>The library requires an instance of server which you create by calling http.createServer(app) meaning an instance of the running express app. You would use this server instance now to listen to 3000 in the index.js file. Also create a sessionHandler which you obtain by calling session({}) with the express-session library</p>
  <pre class="lang-js prettyprint-override"><code>    const WebSocket = require('ws')
      function websocket({ server, sessionHandler, logger }) {
        // https://github.com/websockets/ws/blob/master/examples/express-session-parse/index.js, if you pass a server instance here 'upgrade' handler will crash
        const wss = new WebSocket.Server({ noServer: true })
        function noop() {}
        function heartbeat() {
          this.isAlive = true
        }
        wss.on('connection', (ws, request, client) =&gt; {
          ws.isAlive = true
          ws.on('pong', heartbeat)
          ws.on('message', (msg) =&gt; {
            logger.info(`Received message ${msg} from user ${client}`)
            ws.send(true)
          })
        })
        server.on('upgrade', (request, socket, head) =&gt; {
          sessionHandler(request, {}, () =&gt; {
            logger.info(`${JSON.stringify(request.session)} WEBSOCKET SESSION PARSED`)
            wss.handleUpgrade(request, socket, head, (ws) =&gt; {
              wss.emit('connection', ws, request)
            })
          })
        })
        // TODO use a setTimeout here  instead of a setInterval
        setInterval(function ping() {
          // wss.clients =&gt; Set
          wss.clients.forEach(function each(ws) {
            if (ws.isAlive === false) return ws.terminate()
            ws.isAlive = false
            ws.ping(noop)
          })
        }, 30000)
        return wss
      }
      module.exports = websocket
  </code></pre>
  <ul>
  <li>Does anyone know how I can make this work on the new Nuxt setup without the server folder</li>
  </ul>