1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-14 15:12:48 +01:00
send/server/bin/prod.js
2019-05-03 12:25:12 -04:00

33 lines
826 B
JavaScript

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');
const expressWs = require('express-ws');
if (config.sentry_dsn) {
Raven.config(config.sentry_dsn).install();
}
const app = express();
expressWs(app, null, { perMessageDeflate: false });
routes(app);
app.ws('/api/ws', require('../routes/ws'));
app.use(
express.static(path.resolve(__dirname, '../../dist/'), {
setHeaders: function(res, path) {
if (!/serviceWorker\.js$/.test(path)) {
res.set('Cache-Control', 'public, max-age=31536000, immutable');
}
res.removeHeader('Pragma');
}
})
);
app.use(pages.notfound);
app.listen(config.listen_port, config.listen_address);