강동현

socket.io 추가

import express from 'express';
import socketIo from 'socket.io';
import { createServer } from 'http';
const PORT = 3000;
const app = express();
const PORT = 8008;
const server = createServer(app);
const io = new socketIo.Server(server);
app.get('/', (req, res) => res.send('Express + TypeScript Server'));
io.on('connection', socket => {
console.log('Connected.');
})
app.listen(PORT, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${PORT}`);
});
server.listen(PORT, () => console.log(`Listening on ${PORT}`))
......
......@@ -2,10 +2,12 @@
"dependencies": {
"@types/express": "^4.17.11",
"@types/node": "^15.3.1",
"@types/socket.io": "^3.0.2",
"express": "^4.17.1",
"nodemon": "^2.0.7",
"socket.io": "^4.1.2",
"ts-node": "^9.1.1",
"typescript": "^4.2.4",
"express": "^4.17.1"
"typescript": "^4.2.4"
},
"scripts": {
"start": "nodemon index.ts"
......
This diff is collapsed. Click to expand it.