0fe0e09d62
- added core/shared to watched folders in grunt - moved sentry to shared - moved express initialisation to a shared file - always set trust proxy + sentry error handler - use this new express init everywhere, and remove duplicate trust proxy and sentry error handler code
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
const config = require('../server/config');
|
|
const sentryConfig = config.get('sentry');
|
|
|
|
const expressNoop = function (req, res, next) {
|
|
next();
|
|
};
|
|
|
|
if (sentryConfig && !sentryConfig.disabled) {
|
|
const Sentry = require('@sentry/node');
|
|
const version = require('../server/lib/ghost-version').full;
|
|
Sentry.init({
|
|
dsn: sentryConfig.dsn,
|
|
release: 'ghost@' + version
|
|
});
|
|
|
|
module.exports = {
|
|
requestHandler: Sentry.Handlers.requestHandler(),
|
|
errorHandler: Sentry.Handlers.errorHandler({
|
|
shouldHandleError(error) {
|
|
// Only handle 500 errors for now
|
|
// This is because the only other 5XX error should be 503, which are deliberate maintenance/boot errors
|
|
return (error.statusCode === 500);
|
|
}
|
|
}),
|
|
captureException: Sentry.captureException
|
|
};
|
|
} else {
|
|
module.exports = {
|
|
requestHandler: expressNoop,
|
|
errorHandler: expressNoop,
|
|
captureException: () => {}
|
|
};
|
|
}
|