send/server/bin/prod.js

30 lines
763 B
JavaScript
Raw Normal View History

const express = require('express');
const path = require('path');
const Raven = require('raven');
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');
if (config.sentry_dsn) {
Raven.config(config.sentry_dsn).install();
}
const app = express();
2018-06-21 00:05:33 +00:00
expressWs(app, null, { perMessageDeflate: false });
app.ws('/api/ws', require('../routes/ws'));
routes(app);
app.use(
express.static(path.resolve(__dirname, '../../dist/'), {
setHeaders: function(res) {
res.set('Cache-Control', 'public, max-age=31536000, immutable');
res.removeHeader('Pragma');
}
})
);
app.use(pages.notfound);
2018-01-24 18:23:13 +00:00
app.listen(config.listen_port, config.listen_address);