-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (23 loc) · 834 Bytes
/
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
34
'use strict';
const express = require('express');
const http = require('http');
const config = require('./config');
const chatHandler = require('./chat/handler')();
const morgan = require('morgan');
const io = require('socket.io');
const path = require('path');
const PORT = process.env.PORT || config.port;
// const HOST = process.env.HOST || config.host;
const app = express();
app.use(morgan('dev'));
console.log("Running in", process.env.NODE_ENV);
app.use(express.static( 'build' ));
app.use('/static', express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
const server = http.createServer(app);
chatHandler.init(io(server), app);
server.listen(PORT, () => {
console.log(`Server running at port ${PORT}`) //http://${HOST}:
});