2017-08-24 21:54:02 +00:00
|
|
|
const express = require('express');
|
|
|
|
const path = require('path');
|
|
|
|
const Raven = require('raven');
|
2018-06-22 20:32:24 +00:00
|
|
|
const config = require('../config');
|
|
|
|
const routes = require('../routes');
|
|
|
|
const pages = require('../routes/pages');
|
2018-06-21 00:05:33 +00:00
|
|
|
const expressWs = require('express-ws');
|
2017-08-24 21:54:02 +00:00
|
|
|
|
|
|
|
if (config.sentry_dsn) {
|
|
|
|
Raven.config(config.sentry_dsn).install();
|
|
|
|
}
|
|
|
|
|
|
|
|
const app = express();
|
2018-07-06 22:49:50 +00:00
|
|
|
|
2018-06-21 00:05:33 +00:00
|
|
|
expressWs(app, null, { perMessageDeflate: false });
|
2018-06-22 20:32:24 +00:00
|
|
|
app.ws('/api/ws', require('../routes/ws'));
|
2017-11-06 21:36:36 +00:00
|
|
|
routes(app);
|
|
|
|
|
2017-08-24 21:54:02 +00:00
|
|
|
app.use(
|
2018-06-22 20:32:24 +00:00
|
|
|
express.static(path.resolve(__dirname, '../../dist/'), {
|
2017-08-24 21:54:02 +00:00
|
|
|
setHeaders: function(res) {
|
|
|
|
res.set('Cache-Control', 'public, max-age=31536000, immutable');
|
2017-11-06 21:36:36 +00:00
|
|
|
res.removeHeader('Pragma');
|
2017-08-24 21:54:02 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
app.use(pages.notfound);
|
|
|
|
|
2018-01-24 18:23:13 +00:00
|
|
|
app.listen(config.listen_port, config.listen_address);
|