-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (27 loc) · 1.08 KB
/
app.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
'use strict';
const path = require('path');
const GameController = require('./app/controllers/game-controller');
const express = require('express');
const app = express();
const server = require('http').createServer(app);
const io = require('socket.io')(server);
const favicon = require('serve-favicon');
const lessMiddleware = require('less-middleware');
app.use(lessMiddleware(path.join(__dirname, 'public')));
// Expose all static resources in /public
app.use(express.static(path.join(__dirname, 'public')));
app.use(favicon(path.join(__dirname, 'public', 'favicon.png')));
// Redirect to the main page
app.get('/', (request, response) => {
response.sendFile('game.html', { root: path.join(__dirname, 'app/views') });
});
// Create the main controller
const gameController = new GameController();
gameController.listen(io);
const SERVER_PORT = process.env.PORT || 3000;
app.set('port', SERVER_PORT);
// Start Express server
server.listen(app.get('port'), () => {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
module.exports = app;