-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (34 loc) · 1.07 KB
/
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
/**
* Entry point for 408 Game server.
* @author Team 3
*/
const express = require('express');
const bodyParser = require('body-parser');
const exphbs = require('express-handlebars');
const routing = require('./src/server/router');
const SocketManager = require('./src/server/socket');
/**
* For timestamped console messages.
* It makes for easier debugging.
*/
require('log-timestamp');
const portNumber = process.env.PORT || 8080;
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/', routing);
// Set the view engine to handlebars.
app.set('views', 'src/views/');
app.engine('.hbs', exphbs({
layoutsDir: 'src/views/',
extname: '.hbs'
}));
app.set('view engine', '.hbs');
app.use('/', express.static('./public'));
// Start the node express server listening.
var server = app.listen(portNumber, function() {
console.log('Listening on port:', portNumber);
});
// Set up the server to listen for socket connections with socket io.
const socketManager = new SocketManager();
socketManager.startListening(server);