Harshit Maurya
Sep 9, 2018 · 1 min read

I you want to use 'express' instead of the 'http' module, you can include the following code:

const PORT = 3000;
const
ws = require(`websocket`);
const WebSocketServer = ws.server;
const express = require('express');
const app = express();
const http = require('http').Server(app);

/**
* Express Server
*/
app.use('/', express.static('public'));
http.listen(PORT, function () {
console.log(new Date() + " Server is listening on port: " + PORT);
});
const wsServer = new WebSocketServer({
httpServer: http
});
Harshit Maurya

Written by

Geek | Developer | Musician | Passionate Pizza eater

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade