-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (29 loc) · 1 KB
/
server.js
File metadata and controls
39 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const expressjs = require('express');
const app = expressjs();
const http = require('http');
const { disconnect } = require('process');
const webServer = http.createServer(app);
const {Server} = require('socket.io');
const io = new Server(webServer);
const path = require('path'); // npm install --save path for path management
// get all url form public side
app.use(expressjs.static('public/build'));
app.get('*', function(req, res){
// send all url in back-end server side
res.sendFile(path.resolve(__dirname, 'public', 'build', 'index.html'))
})
app.get('/express-server', function(req, res){
res.end("This massage just for testing backend work or not...!")
})
// user connection alart
io.on('connection', function(socket){
console.log('New user connected: ');
socket.on('disconnect', function(){
console.log('User is disconnected.');
})
})
// add port address
let port = 5000;
webServer.listen(port, function(){
console.log('Server running address is: loaclhost:'+port)
})