forked from tomds/buzzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (29 loc) · 948 Bytes
/
server.js
File metadata and controls
37 lines (29 loc) · 948 Bytes
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
require('dotenv').config(); //Load dot env variables
var express = require('express');
var engines = require('consolidate');
var http = require('http');
var io = require('socket.io');
var clientConnection = require('./clientConnection');
var port = process.env.PORT || 3000;
var app = express();
var server = http.createServer(app);
io = io.listen(server);
var listener = server.listen(port,
() => {
let addr = listener.address();
console.log(`http://localhost:${addr.port}`);
console.log(`http://localhost:${addr.port}/host`);
});
app.engine('html', engines.hogan);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(express.static('public'));
app.get('/', function (req, res) {
res.render('index');
});
app.get('/host', function (req, res) {
res.render('index', { host: true });
});
io.sockets.on('connection', function (socket) {
clientConnection.init(socket);
});