2021-03-16 19:34:11 -04:00
|
|
|
// Generated by CoffeeScript 2.5.1
|
|
|
|
(function() {
|
2021-10-26 08:45:05 -04:00
|
|
|
var ENV_DEV, ENV_DOCKER, ENV_PROD, Sentry, Tracing, app, envresult, favicons, log, original_page, original_text, server, unread_counts;
|
2021-03-17 09:31:19 -04:00
|
|
|
|
|
|
|
Sentry = require("@sentry/node");
|
|
|
|
|
|
|
|
Tracing = require("@sentry/tracing");
|
2021-03-16 19:34:11 -04:00
|
|
|
|
|
|
|
app = require('express')();
|
|
|
|
|
2021-03-16 20:07:46 -04:00
|
|
|
server = require('http').createServer(app);
|
2021-03-16 19:34:11 -04:00
|
|
|
|
|
|
|
log = require('./log.js');
|
|
|
|
|
2021-03-17 09:34:55 -04:00
|
|
|
envresult = require('dotenv').config({
|
|
|
|
path: 'node/.env'
|
|
|
|
});
|
2021-03-17 09:10:37 -04:00
|
|
|
|
2021-03-17 09:31:19 -04:00
|
|
|
if (envresult.error) {
|
2021-03-17 09:34:55 -04:00
|
|
|
// throw envresult.error
|
|
|
|
envresult = require('dotenv').config();
|
|
|
|
if (envresult.error) {
|
2021-10-19 13:00:30 -04:00
|
|
|
log.debug(" ---> No .env file found, using defaults");
|
2021-03-17 09:34:55 -04:00
|
|
|
}
|
2021-03-17 09:31:19 -04:00
|
|
|
}
|
2021-03-17 09:10:37 -04:00
|
|
|
|
2021-10-19 13:00:30 -04:00
|
|
|
// throw envresult.error
|
2021-03-17 09:43:25 -04:00
|
|
|
ENV_DEV = process.env.NODE_ENV === 'development';
|
|
|
|
|
|
|
|
ENV_PROD = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
|
|
ENV_DOCKER = process.env.NODE_ENV === 'docker';
|
|
|
|
|
2021-03-16 19:34:11 -04:00
|
|
|
original_page = require('./original_page.js').original_page;
|
|
|
|
|
|
|
|
original_text = require('./original_text.js').original_text;
|
|
|
|
|
|
|
|
favicons = require('./favicons.js').favicons;
|
|
|
|
|
|
|
|
unread_counts = require('./unread_counts.js').unread_counts;
|
|
|
|
|
2021-03-17 09:43:25 -04:00
|
|
|
if (!ENV_DEV && !ENV_PROD && !ENV_DOCKER) {
|
|
|
|
throw new Error("Set envvar NODE_ENV=<development,docker,production>");
|
|
|
|
}
|
2021-03-17 09:10:37 -04:00
|
|
|
|
2021-03-17 09:43:25 -04:00
|
|
|
if (ENV_PROD) {
|
|
|
|
Sentry.init({
|
|
|
|
dsn: process.env.SENTRY_DSN,
|
2021-03-17 10:05:26 -04:00
|
|
|
debug: true,
|
2021-10-26 08:42:49 -04:00
|
|
|
tracesSampleRate: 1.0,
|
2021-10-26 08:45:05 -04:00
|
|
|
serverName: process.env.SERVER_NAME
|
2021-03-17 09:43:25 -04:00
|
|
|
});
|
|
|
|
app.use(Sentry.Handlers.requestHandler());
|
|
|
|
}
|
2021-03-17 09:10:37 -04:00
|
|
|
|
2021-03-16 19:34:11 -04:00
|
|
|
original_page(app);
|
|
|
|
|
|
|
|
original_text(app);
|
|
|
|
|
|
|
|
favicons(app);
|
|
|
|
|
|
|
|
unread_counts(server);
|
|
|
|
|
2021-03-17 09:43:25 -04:00
|
|
|
if (ENV_PROD) {
|
|
|
|
app.get("/debug", function(req, res) {
|
|
|
|
throw new Error("Debugging Sentry");
|
|
|
|
});
|
|
|
|
app.use(Sentry.Handlers.errorHandler());
|
2021-03-17 09:59:13 -04:00
|
|
|
log.debug(`Setting up Sentry debugging: ${process.env.SENTRY_DSN.substr(0, 20)}...`);
|
2021-03-17 09:43:25 -04:00
|
|
|
}
|
2021-03-17 09:10:37 -04:00
|
|
|
|
2021-04-15 19:12:51 -04:00
|
|
|
log.debug(`Starting NewsBlur Node Server: ${process.env.SERVER_NAME || 'localhost'}`);
|
2021-03-16 19:34:11 -04:00
|
|
|
|
2021-03-16 20:07:46 -04:00
|
|
|
server.listen(8008);
|
2021-03-16 19:34:11 -04:00
|
|
|
|
|
|
|
}).call(this);
|