1
0
mirror of https://github.com/seejohnrun/haste-server.git synced 2026-01-22 20:07:10 +00:00

Integrate sentry

This commit is contained in:
John Crepezzi
2020-10-06 12:08:59 -04:00
parent 319141afd0
commit 339271e819
3 changed files with 152 additions and 1 deletions

View File

@@ -10,6 +10,13 @@ var connect_rate_limit = require('connect-ratelimit');
var DocumentHandler = require('./lib/document_handler');
const Sentry = require('@sentry/node');
const sentryEnabled = process.env.SENTRY_DSN;
if (sentryEnabled) {
Sentry.init({dsn: process.env.SENTRY_DSN});
}
// Load the configuration and set some defaults
var config = JSON.parse(fs.readFileSync('./config.js', 'utf8'));
config.port = process.env.PORT || config.port || 7777;
@@ -100,6 +107,9 @@ var documentHandler = new DocumentHandler({
var app = connect();
// Include sentry request handler if enabled
if (sentryEnabled) app.use(Sentry.Handlers.requestHandler());
// Rate limit all requests
if (config.rateLimits) {
config.rateLimits.end = true;
@@ -150,6 +160,9 @@ app.use(connect_st({
index: 'index.html'
}));
// Include sentry error handler if enabled
if (sentryEnabled) { app.use(Sentry.Handlers.errorHandler()); }
http.createServer(app).listen(config.port, config.host);
winston.info('listening on ' + config.host + ':' + config.port);