-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (34 loc) · 1.04 KB
/
server.js
File metadata and controls
40 lines (34 loc) · 1.04 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
40
'use strict';
/**
* server
* @author Jared Grady
* @license MIT license
*/
const express = require('express');
const app = express();
const http = require('http').Server(app);
const compression = require('compression');
const helmet = require('helmet');
const chalk = require('chalk');
const winston = require('winston');
const RoomList = require('./src/roomlist.js');
const port = process.env.PORT || 3000;
/* Set up express middleware before launch */
app.set('view engine', 'html');
app.engine('html', require('ejs').renderFile);
app.set('views', __dirname + '/views');
app.use(compression());
app.use(helmet({noSniff: false}));
app.use(express.static(__dirname + '/public'));
/* Set up our routes */
app.use('/', require('./src/router'));
/* Set up our sockets */
const io = require('socket.io')(http);
require('./src/sockets')(io);
/* Set up our globals */
global.rooms = new RoomList();
/* Finally, start listening */
http.listen(port, error => {
if (error) winston.error(error);
winston.info("Now listening on port " + chalk.green(port));
});