drop.chapril.org-firefoxsend/server/bin/prod.js

33 lines
845 B
JavaScript
Raw Normal View History

const express = require('express');
const path = require('path');
const Sentry = require('@sentry/node');
const config = require('../config');
const routes = require('../routes');
const pages = require('../routes/pages');
const expressWs = require('@dannycoates/express-ws');
if (config.sentry_dsn) {
Sentry.init({ dsn: config.sentry_dsn });
}
const app = express();
2018-07-07 00:49:50 +02:00
2018-06-21 02:05:33 +02:00
expressWs(app, null, { perMessageDeflate: false });
routes(app);
2019-05-03 18:25:12 +02:00
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);
2018-01-24 19:23:13 +01:00
app.listen(config.listen_port, config.listen_address);