-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
24 lines (21 loc) · 650 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
const http = require('http');
const os = require('os');
const path = require('path');
const express = require('express');
const history = require('express-history-api-fallback');
const socketIo = require('socket.io');
const app = express();
const server = http.Server(app);
const io = socketIo(server);
const root = path.resolve('client');
const host = os.hostname();
const port = process.env.PORT || 3000;
// serve static
app.use(express.static(root));
app.use(history('index.html', { root }));
// manage users
io.on('connection', require('./server'));
// start listening
server.listen(port, () => {
console.log('http://%s:%d', host, port);
});