Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-better-error-handler

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-better-error-handler - npm Package Compare versions

Comparing version 3.0.1 to 3.0.3

.lib.eslintrc

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"cda59ecf-3869-44a7-bb6f-25345e876788":{"parent":null,"children":["d48e8d1c-b1f4-4285-a78e-a8721177360c"]},"d48e8d1c-b1f4-4285-a78e-a8721177360c":{"parent":"cda59ecf-3869-44a7-bb6f-25345e876788","children":[]}},"files":{"/Users/jack/Projects/koa-better-error-handler/lib/index.js":["d48e8d1c-b1f4-4285-a78e-a8721177360c"]},"externalIds":{}}
{"processes":{"ddb73522-3a22-4d09-a401-82c7e745339e":{"parent":null,"children":["f1b9c710-18d1-469d-921a-92f7b2ea9db5"]},"f1b9c710-18d1-469d-921a-92f7b2ea9db5":{"parent":"ddb73522-3a22-4d09-a401-82c7e745339e","children":[]}},"files":{"/Users/jack/Projects/koa-better-error-handler/lib/index.js":["f1b9c710-18d1-469d-921a-92f7b2ea9db5"]},"externalIds":{}}

@@ -1,4 +0,40 @@

'use strict';
"use strict";
// initialize try/catch error handling right away
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
const fs = require('fs');
const path = require('path');
const Boom = require('@hapi/boom');
const Debug = require('debug');
const _ = require('lodash');
const capitalize = require('capitalize');
const camelCase = require('camelcase');
const co = require('co');
const humanize = require('humanize-string');
const statuses = require('statuses');
const toIdentifier = require('toidentifier');
const opts = {
encoding: 'utf8'
}; // error pages were inspired by HTML5 Boilerplate's default 404.html page
// https://github.com/h5bp/html5-boilerplate/blob/master/src/404.html
const _404 = fs.readFileSync(path.join(__dirname, '..', '404.html'), opts);
const _500 = fs.readFileSync(path.join(__dirname, '..', '500.html'), opts);
const debug = new Debug('koa-better-error-handler');
const passportLocalMongooseErrorNames = ['AuthenticationError', 'MissingPasswordError', 'AttemptTooSoonError', 'TooManyAttemptsError', 'NoSaltValueStoredError', 'IncorrectPasswordError', 'IncorrectUsernameError', 'MissingUsernameError', 'UserExistsError']; // initialize try/catch error handling right away
// adapted from: https://github.com/koajs/onerror/blob/master/index.js

@@ -10,10 +46,12 @@ // https://github.com/koajs/examples/issues/20#issuecomment-31568401

// https://goo.gl/8Z7aMe
// eslint-disable-next-line complexity
// eslint-disable-next-line complexity
let errorHandler = (() => {
var _ref = _asyncToGenerator(function* (err) {
function errorHandler(_x) {
return _errorHandler.apply(this, arguments);
}
function _errorHandler() {
_errorHandler = _asyncToGenerator(function* (err) {
if (!err) return;
if (!_.isError(err)) err = new Error(err);
const type = this.accepts(['text', 'json', 'html']);

@@ -25,35 +63,30 @@

err.message = Boom.notAcceptable().output.payload;
}
} // parse mongoose validation errors
// parse mongoose validation errors
err = parseValidationError(this, err);
// check if we threw just a status code in order to keep it simple
err = parseValidationError(this, err); // check if we threw just a status code in order to keep it simple
const val = parseInt(err.message, 10);
if (_.isNumber(val) && val >= 400) err = Boom.create(val);
if (_.isNumber(val) && val >= 400) err = Boom[camelCase(toIdentifier(statuses[val]))](); // check if we have a boom error that specified
// a status code already for us (and then use it)
// check if we have a boom error that specified
// a status code already for us (and then use it)
if (_.isObject(err.output) && _.isNumber(err.output.statusCode)) err.status = err.output.statusCode;
if (!_.isNumber(err.status)) err.status = 500; // check if there is flash messaging
if (!_.isNumber(err.status)) err.status = 500;
// check if there is flash messaging
const hasFlash = _.isFunction(this.flash);
debug('hasFlash', hasFlash);
// check if there is session support
debug('hasFlash', hasFlash); // check if there is session support
const hasSessions = _.isObject(this.session) && _.isObject(this.sessionStore) && _.isString(this.sessionId) && _.isObject(this.session) && _.isFunction(this.sessionStore.set);
debug('hasSessions', hasSessions);
// check if there is a view rendering engine binding `this.render`
debug('hasSessions', hasSessions); // check if there is a view rendering engine binding `this.render`
const hasRender = _.isFunction(this.render);
debug('hasRender', hasRender);
// check if we're about to go into a possible endless redirect loop
const noReferrer = this.get('Referrer') === '';
debug('hasRender', hasRender); // check if we're about to go into a possible endless redirect loop
// nothing we can do here other
const noReferrer = this.get('Referrer') === ''; // nothing we can do here other
// than delegate to the app-level
// handler and log.
if (this.headerSent || !this.writable) {

@@ -63,6 +96,6 @@ debug('headers were already sent, returning early');

return;
}
} // populate the status and body with `boom` error message payload
// (e.g. you can do `ctx.throw(404)` and it will output a beautiful err obj)
// populate the status and body with `boom` error message payload
// (e.g. you can do `ctx.throw(404)` and it will output a beautiful err obj)
err.status = err.status || 500;

@@ -72,13 +105,11 @@ err.statusCode = err.status;

this.status = this.statusCode;
this.body = Boom.create(err.status, err.message).output.payload;
this.body = new Boom(err.message, {
statusCode: err.status
}).output.payload; // set any additional error headers specified
// (e.g. for BasicAuth we use `basic-auth` which specifies WWW-Authenticate)
// set any additional error headers specified
// (e.g. for BasicAuth we use `basic-auth` which specifies WWW-Authenticate)
if (_.isObject(err.headers) && Object.keys(err.headers).length > 0) this.set(err.headers);
debug('status code was %d', this.status);
this.app.emit('error', err, this); // fix page title and description
this.app.emit('error', err, this);
// fix page title and description
this.state.meta = this.state.meta || {};

@@ -89,3 +120,2 @@ this.state.meta.title = this.body.error;

debug('set `this.state.meta.desc` to %s', this.state.meta.description);
debug('type was %s', type);

@@ -115,8 +145,6 @@

// would endlessly rediret the user with `this.redirect('back')`
if (noReferrer) debug('prevented endless redirect loop!');
if (noReferrer) debug('prevented endless redirect loop!'); // flash an error message
// flash an error message
if (hasFlash) this.flash('error', err.message);
if (hasFlash) this.flash('error', err.message); // render the 500 page
// render the 500 page
if (hasRender) {

@@ -135,6 +163,5 @@ try {

// flash an error message
if (hasFlash) this.flash('error', err.message);
if (hasFlash) this.flash('error', err.message); // TODO: until the issue is resolved, we need to add this here
// <https://github.com/koajs/generic-session/pull/95#issuecomment-246308544>
// TODO: until the issue is resolved, we need to add this here
// <https://github.com/koajs/generic-session/pull/95#issuecomment-246308544>
if (this.sessionStore && this.sessionId && this.session && this.state.cookiesKey) {

@@ -144,3 +171,2 @@ yield co.wrap(this.sessionStore.set).call(this.sessionStore, this.sessionId, this.session);

}
/*

@@ -158,4 +184,5 @@ // if we're using `koa-session-store` we need to add

*/
// redirect the user to the page they were just on
// redirect the user to the page they were just on
this.redirect('back');

@@ -165,2 +192,3 @@ }

break;
case 'json':

@@ -170,2 +198,3 @@ this.type = 'json';

break;
default:

@@ -180,63 +209,35 @@ this.type = this.api ? 'json' : 'text';

});
return _errorHandler.apply(this, arguments);
}
return function errorHandler(_x) {
return _ref.apply(this, arguments);
};
})();
function parseValidationError(ctx, err) {
// translate messages
const translate = message => _.isFunction(ctx.request.t) ? ctx.request.t(message) : message; // passport-local-mongoose support
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('fs');
const path = require('path');
const s = require('underscore.string');
const co = require('co');
const Debug = require('debug');
const _ = require('lodash');
const Boom = require('boom');
if (passportLocalMongooseErrorNames.includes(err.name)) {
err.message = translate(err.message); // this ensures the error shows up client-side
const opts = {
encoding: 'utf8'
};
err.status = 400; // 429 = too many requests
// error pages were inspired by HTML5 Boilerplate's default 404.html page
// https://github.com/h5bp/html5-boilerplate/blob/master/src/404.html
const _404 = fs.readFileSync(path.join(__dirname, '..', '404.html'), opts);
const _500 = fs.readFileSync(path.join(__dirname, '..', '500.html'), opts);
const debug = new Debug('koa-better-error-handler');
const passportLocalMongooseErrorNames = ['AuthenticationError', 'MissingPasswordError', 'AttemptTooSoonError', 'TooManyAttemptsError', 'NoSaltValueStoredError', 'IncorrectPasswordError', 'IncorrectUsernameError', 'MissingUsernameError', 'UserExistsError'];
function parseValidationError(ctx, err) {
// translate messages
const translate = message => _.isFunction(ctx.request.t) ? ctx.request.t(message) : message;
// passport-local-mongoose support
if (passportLocalMongooseErrorNames.includes(err.name)) {
err.message = translate(err.message);
// this ensures the error shows up client-side
err.status = 400;
// 429 = too many requests
if (['AttemptTooSoonError', 'TooManyAttemptsError'].includes(err.name)) err.status = 429;
return err;
}
} // inspired by https://github.com/syntagma/mongoose-error-helper
// inspired by https://github.com/syntagma/mongoose-error-helper
if (err.name !== 'ValidationError') return err;
// transform the error messages to be humanized as adapted from:
if (err.name !== 'ValidationError') return err; // transform the error messages to be humanized as adapted from:
// https://github.com/niftylettuce/mongoose-validation-error-transform
err.errors = _.map(err.errors, error => {
if (!_.isString(error.path)) {
error.message = s.capitalize(error.message);
error.message = capitalize(error.message);
return error;
}
error.message = error.message.replace(new RegExp(error.path, 'g'), s.humanize(error.path));
error.message = s.capitalize(error.message);
error.message = error.message.replace(new RegExp(error.path, 'g'), humanize(error.path));
error.message = capitalize(error.message);
return error;
});
}); // loop over the errors object of the Validation Error
// with support for HTML error lists
// loop over the errors object of the Validation Error
// with support for HTML error lists
if (_.values(err.errors).length === 1) {

@@ -246,12 +247,11 @@ err.message = translate(_.values(err.errors)[0].message);

const errors = _.map(_.map(_.values(err.errors), 'message'), translate);
err.message = ctx.api ? errors.join(', ') : `<ul class="text-left mb-0"><li>${errors.join('</li><li>')}</li></ul>`;
}
} // this ensures the error shows up client-side
// this ensures the error shows up client-side
err.status = 400;
return err;
}
module.exports = errorHandler;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW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xuXG4gIC8vIGxvb3Agb3ZlciB0aGUgZXJyb3JzIG9iamVjdCBvZiB0aGUgVmFsaWRhdGlvbiBFcnJvclxuICAvLyB3aXRoIHN1cHBvcnQgZm9yIEhUTUwgZXJyb3IgbGlzdHNcbiAgaWYgKF8udmFsdWVzKGVyci5lcnJvcnMpLmxlbmd0aCA9PT0gMSkge1xuICAgIGVyci5tZXNzYWdlID0gdHJhbnNsYXRlKF8udmFsdWVzKGVyci5lcnJvcnMpWzBdLm1lc3NhZ2UpO1xuICB9IGVsc2Uge1xuICAgIGNvbnN0IGVycm9ycyA9IF8ubWFwKF8ubWFwKF8udmFsdWVzKGVyci5lcnJvcnMpLCAnbWVzc2FnZScpLCB0cmFuc2xhdGUpO1xuICAgIGVyci5tZXNzYWdlID0gY3R4LmFwaVxuICAgICAgPyBlcnJvcnMuam9pbignLCAnKVxuICAgICAgOiBgPHVsIGNsYXNzPVwidGV4dC1sZWZ0IG1iLTBcIj48bGk+JHtlcnJvcnMuam9pbignPC9saT48bGk+Jyl9PC9saT48L3VsPmA7XG4gIH1cblxuICAvLyB0aGlzIGVuc3VyZXMgdGhlIGVycm9yIHNob3dzIHVwIGNsaWVudC1zaWRlXG4gIGVyci5zdGF0dXMgPSA0MDA7XG5cbiAgcmV0dXJuIGVycjtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBlcnJvckhhbmRsZXI7XG4iXX0=
module.exports = errorHandler;
{
"name": "koa-better-error-handler",
"description": "A better error-handler for Lad and Koa. Makes `ctx.throw` awesome (best used with koa-404-handler)",
"version": "3.0.1",
"version": "3.0.3",
"author": "Nick Baugh <niftylettuce@gmail.com>",

@@ -16,14 +16,19 @@ "bugs": "https://github.com/ladjs/koa-better-error-handler/issues",

"dependencies": {
"boom": "5.1.0",
"@hapi/boom": "^7.4.3",
"camelcase": "^5.3.1",
"capitalize": "^2.0.0",
"co": "^4.6.0",
"debug": "^4.1.1",
"humanize-string": "^2.1.0",
"lodash": "^4.17.15",
"underscore.string": "^3.3.5"
"statuses": "^1.5.0",
"toidentifier": "^1.0.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"ava": "^2.3.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"codecov": "^3.5.0",

@@ -33,2 +38,3 @@ "cross-env": "^5.2.1",

"eslint-config-xo-lass": "^1.0.3",
"eslint-plugin-node": "^10.0.0",
"fixpack": "^2.3.1",

@@ -38,3 +44,3 @@ "husky": "^3.0.5",

"koa-404-handler": "^0.0.2",
"koa-basic-auth": "https://github.com/niftylettuce/basic-auth",
"koa-basic-auth": "^4.0.0",
"koa-connect-flash": "^0.1.2",

@@ -59,3 +65,3 @@ "koa-convert": "^1.2.0",

"hooks": {
"pre-commit": "npm test",
"pre-commit": "lint-staged && npm test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"

@@ -89,16 +95,14 @@ }

"lint-staged": {
"linters": {
"*.js": [
"xo --fix",
"git add"
],
"*.md": [
"remark . -qfo",
"git add"
],
"package.json": [
"fixpack",
"git add"
]
}
"*.js": [
"xo --fix",
"git add"
],
"*.md": [
"remark . -qfo",
"git add"
],
"package.json": [
"fixpack",
"git add"
]
},

@@ -120,3 +124,3 @@ "main": "lib/index.js",

"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "xo && remark . -qfo",
"lint": "xo && remark . -qfo && eslint --no-inline-config -c .lib.eslintrc lib",
"precommit": "lint-staged && npm test",

@@ -123,0 +127,0 @@ "test": "npm run build && npm run lint && npm run test-coverage",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc