Cleanup more Sentry

This commit is contained in:
Jonathan Cremin 2019-01-14 22:43:10 +00:00
parent 1a9f510472
commit c6dc673ab5
2 changed files with 4 additions and 14 deletions

View file

@ -48,10 +48,6 @@ router.use(async (ctx, next) => {
}, },
}; };
} else if (!err.status) { } else if (!err.status) {
debug(err);
if (ctx.Sentry) {
ctx.Sentry.captureException(err);
}
throw err; throw err;
} else { } else {
ctx.status = err.status; ctx.status = err.status;

14
app.js
View file

@ -19,6 +19,8 @@ const debug = debugname('hostr');
const app = websockify(new Koa()); const app = websockify(new Koa());
app.keys = [process.env.COOKIE_KEY]; app.keys = [process.env.COOKIE_KEY];
app.use(bodyparser());
if (process.env.SENTRY_DSN) { if (process.env.SENTRY_DSN) {
Sentry.init({ Sentry.init({
dsn: process.env.SENTRY_DSN, dsn: process.env.SENTRY_DSN,
@ -30,14 +32,7 @@ if (process.env.SENTRY_DSN) {
debug('Reported error', eventId); debug('Reported error', eventId);
}); });
}); });
app.use(async (ctx, next) => { app.context.Sentry = Sentry;
ctx.Sentry = Sentry;
await next();
});
app.ws.use(async (ctx, next) => {
ctx.Sentry = Sentry;
await next();
});
} }
app.use(helmet()); app.use(helmet());
@ -63,11 +58,10 @@ app.use(async (ctx, next) => {
app.use(session(app)); app.use(session(app));
app.use(redis.middleware()); app.use(redis.middleware());
if (process.env.DEBUG === 'true') { if (app.env === 'development') {
app.use(logger()); app.use(logger());
} }
app.use(compress()); app.use(compress());
app.use(bodyparser());
app.use(favicon(path.join(__dirname, 'web/public/images/favicon.png'))); app.use(favicon(path.join(__dirname, 'web/public/images/favicon.png')));
app.use(serve(path.join(__dirname, 'web/public/'), { maxage: 31536000000 })); app.use(serve(path.join(__dirname, 'web/public/'), { maxage: 31536000000 }));