diff --git a/server/index.js b/server/index.js new file mode 100644 index 0000000..62424ba --- /dev/null +++ b/server/index.js @@ -0,0 +1,15 @@ +const app = require('express')(); +const server = require('http').createServer(app); +const io = require('socket.io')(server); + +io.on('connection', socket => { + console.log(`Client connected with id: ${socket.id}!`); // A client connects + + socket.on('data', (data) => { + console.log('Received from client: ', data); // Received data from client + }); +}); + +server.listen(3000, () => { + console.log('Server is listening on port 3000!'); // Started server +}); \ No newline at end of file diff --git a/server/package.json b/server/package.json new file mode 100644 index 0000000..b853536 --- /dev/null +++ b/server/package.json @@ -0,0 +1,18 @@ +{ + "name": "server", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "run": "node index.js", + "dev": "nodemon index.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.17.1", + "nodemon": "^2.0.7", + "socket.io": "^3.1.0" + } +}