-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (24 loc) · 790 Bytes
/
index.js
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
40
41
42
43
44
45
46
47
// Dependencies
const express = require('express');
const socketIo = require('socket.io');
// Contollers
const locationController = require('./controllers/locationController');
// SetUp
const app = express();
const server = require('http').createServer(app);
const io = socketIo(server);
// Start Server
const PORT = process.env.PORT || 80;
server.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
// Sockets ----
io.on('connection', locationController.handleSocketConnection);
// Routes ----
app.use(express.static(__dirname + '/public'));
app.set('view engine', 'ejs');
const routes = require('./routes/index');
app.use('/', routes);
app.all('*', (req, res) => {
res.redirect('/')
})