Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Joi.validate(options, schema, (err) => {
if (err) {
return next(err);
}
Rollbar.init(options.rollbar.accessToken, {
environment: options.env
});
Rollbar.handleUncaughtExceptionsAndRejections(options.rollbar.accessToken, {
exitOnUncaughtException: true
});
plugin.on('request-error', (request, err) => {
Rollbar.handleError(err, request);
});
return next();
});
};
function rollbar (server, options, next) {
if (process.env.ROLLBAR_ACCESS_TOKEN) {
const rollbar = require('rollbar')
rollbar.init(process.env.ROLLBAR_ACCESS_TOKEN, {
env: process.env.NODE_ENV
})
rollbar.handleUncaughtExceptionsAndRejections(process.env.POST_SERVER_ITEM_ACCESS_TOKEN, {
exitOnUncaughtException: true
})
server.on('log', (event, tags) => {
if (!tags.error) {
return
}
rollbar.reportMessage(event.data)
})
}
next()
}