socket IO setup (express server)

PHOTO EMBED

Wed Aug 18 2021 16:34:21 GMT+0000 (UTC)

Saved by @ExplodeMilk #typescript

import express from 'express';
import http from 'http';
import {Server as SocketIO} from 'socket.io';

//....
const app = express();
const server = new http.Server(app);
const io = new SocketIO(server);

io.on('connection', function (socket) {
    console.log(socket);
});
//....
const PORT = 8080;
server.listen(PORT, () => {
    console.log(`Listening at http://localhost:${PORT}/`);
});
content_copyCOPY

install typescript by <npm install typescript ts-node @types.node> install express by <npm install express @types/express> install socket IO by <npm install socket.io @types/socket.io>