* fix(models.user): Colocate all user methods Moved user methods/extensions into one file. Tracked down `next method called more than once` error and setting headers after their sent. Let regular error handler handle api errors as well. * feat(server.auth): Disable github account creation We are no longer allowing account creation through github * refactor(Auth): Move user identity link into models dir * feat(Disable link account login): This removes the ability to use a linked account t * feat(errorhandlers): Add opbeat, filter out handled error
31 lines
799 B
JavaScript
31 lines
799 B
JavaScript
import opbeat from 'opbeat';
|
|
import debug from 'debug';
|
|
|
|
import {
|
|
isHandledError,
|
|
unwrapHandledError
|
|
} from '../utils/create-handled-error.js';
|
|
|
|
const log = debug('fcc:middlewares:error-reporter');
|
|
|
|
export default function keymetrics() {
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
return (err, req, res, next) => {
|
|
if (isHandledError(err)) {
|
|
// log out user messages in development
|
|
const handled = unwrapHandledError(err);
|
|
log(handled.message);
|
|
}
|
|
next(err);
|
|
};
|
|
}
|
|
return (err, req, res, next) => {
|
|
// handled errors do not need to be reported
|
|
// the report a message and redirect the user
|
|
if (isHandledError(err)) {
|
|
return next(err);
|
|
}
|
|
return opbeat.captureError(err, { request: req }, () => next(err));
|
|
};
|
|
}
|