Skip to content

Commit

Permalink
feat: upgraded deps, switched boom to @hapi/boom, fixed deps
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Sep 5, 2019
1 parent ee98738 commit c87649d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 56 deletions.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
"Nick Baugh <niftylettuce@gmail.com>"
],
"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": "^0.0.9",
"lodash": "^4.17.15",
"underscore.string": "^3.3.5"
"statuses": "^1.5.0",
"toidentifier": "^1.0.0"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
Expand All @@ -33,7 +37,7 @@
"husky": "^3.0.5",
"koa": "^2.8.1",
"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",
"koa-convert": "^1.2.0",
"koa-generic-session": "^2.0.1",
Expand Down
22 changes: 14 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const fs = require('fs');
const path = require('path');
const s = require('underscore.string');
const co = require('co');

const Boom = require('@hapi/boom');
const Debug = require('debug');
const _ = require('lodash');
const Boom = require('boom');
const capitalize = require('capitalize');
const camelCase = require('camelcase');
const co = require('co');
const humanize = require('humanize');
const statuses = require('statuses');
const toIdentifier = require('toidentifier');

const opts = {
encoding: 'utf8'
Expand Down Expand Up @@ -56,7 +61,8 @@ async function errorHandler(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)
Expand Down Expand Up @@ -100,7 +106,7 @@ async function errorHandler(err) {
err.statusCode = err.status;
this.statusCode = err.statusCode;
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)
Expand Down Expand Up @@ -236,15 +242,15 @@ function parseValidationError(ctx, err) {
// 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)
humanize(error.path)
);
error.message = s.capitalize(error.message);
error.message = capitalize(error.message);
return error;
});

Expand Down
88 changes: 43 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,18 @@
dependencies:
arrify "^1.0.1"

"@hapi/boom@^7.4.3":
version "7.4.3"
resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-7.4.3.tgz#79ffed6ef8c625046a3bd069abed5a9d35fc50c1"
integrity sha512-3di+R+BcGS7HKy67Zi6mIga8orf67GdR0ubDEVBG1oqz3y9B70LewsuCMCSvWWLKlI6V1+266zqhYzjMrPGvZw==
dependencies:
"@hapi/hoek" "8.x.x"

"@hapi/hoek@8.x.x":
version "8.2.2"
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.2.2.tgz#6eaa2e1ec3b50dfb8dccbe705dc289094652bc2d"
integrity sha512-18P3VwngjNEcmvPj1mmiHLPyUPjhPAxIyJKDj4PRIY0F5ac3P0Vd0hkASPyWXHK0rfY3P9N2FoxV8ZuYaRBZ1g==

"@marionebl/sander@^0.6.0":
version "0.6.1"
resolved "https://registry.yarnpkg.com/@marionebl/sander/-/sander-0.6.1.tgz#1958965874f24bc51be48875feb50d642fc41f7b"
Expand Down Expand Up @@ -501,9 +513,9 @@
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/node@*", "@types/node@^12.0.2":
version "12.7.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.3.tgz#27b3f40addaf2f580459fdb405222685542f907a"
integrity sha512-3SiLAIBkDWDg6vFo0+5YJyHPWU9uwu40Qe+v+0MH8wRKYBimHvvAOyk3EzMrD/TrIlLYfXrqDqrg913PynrMJQ==
version "12.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.4.tgz#64db61e0359eb5a8d99b55e05c729f130a678b04"
integrity sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -1530,13 +1542,6 @@ blueimp-md5@^2.10.0:
resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.12.0.tgz#be7367938a889dec3ffbb71138617c117e9c130a"
integrity sha512-zo+HIdIhzojv6F1siQPqPFROyVy7C50KzHv/k/Iz+BtvtVzSHXiMXOpq2wCfNkeBqdCv+V8XOV96tsEt2W/3rQ==

boom@5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/boom/-/boom-5.1.0.tgz#0308fa8e924cd6d42d9c3bf4883bdc98f0e71df8"
integrity sha1-Awj6jpJM1tQtnDv0iDvcmPDnHfg=
dependencies:
hoek "4.x.x"

boxen@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b"
Expand Down Expand Up @@ -1736,6 +1741,11 @@ caniuse-lite@^1.0.30000844:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000989.tgz#b9193e293ccf7e4426c5245134b8f2a56c0ac4b9"
integrity sha512-vrMcvSuMz16YY6GSVZ0dWDTJP8jqk3iFQ/Aq5iqblPwxSVVZI+zxDyTX0VPqtQsDnfdrBDcsmhgTEOh5R8Lbpw==

capitalize@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/capitalize/-/capitalize-2.0.0.tgz#61859dd952aba244f03541b23e11470ada097f4b"
integrity sha512-HwGrAbSn44Tm5Nz+m02oQHf+9y771rmb/cTbXFcoADy29LFRCj4PhWBT54qxfY2HJBWBplwx17Pd4ek6OFbr/Q==

capture-stack-trace@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d"
Expand Down Expand Up @@ -2607,9 +2617,9 @@ ee-first@1.1.1:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=

electron-to-chromium@^1.3.47:
version "1.3.250"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.250.tgz#1f383c16aeb75e7bddbd6a0491237eca81b2cb1f"
integrity sha512-2OAU91iUw83QvzuWJPfT+FMj+O+DC1EyTx1QBFcc9WZzOQSfZEAWINpdLWElxkgfiqTvQRDOKg0DkMZd9QoNug==
version "1.3.252"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.252.tgz#5b6261965b564a0f4df0f1c86246487897017f52"
integrity sha512-NWJ5TztDnjExFISZHFwpoJjMbLUifsNBnx7u2JI0gCw6SbKyQYYWWtBHasO/jPtHym69F4EZuTpRNGN11MT/jg==

elegant-spinner@^1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -2681,9 +2691,9 @@ error-inject@^1.0.0:
integrity sha1-4rPZG1Su1nLzCdlQ0VSFD6EdTzc=

es-abstract@^1.12.0, es-abstract@^1.7.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.14.0.tgz#f59d9d44278ea8f90c8ff3de1552537c2fd739b4"
integrity sha512-lri42nNq1tIohUuwFBYEM3wKwcrcJa78jukGDdWsuaNxTtxBFGFkKUQ15nc9J+ipje4mhbQR6JwABb4VvawR3A==
version "1.14.1"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.14.1.tgz#6e8d84b445ec9c610781e74a6d52cc31aac5b4ca"
integrity sha512-cp/Tb1oA/rh2X7vqeSOvM+TSo3UkJLX70eNihgVEvnzwAgikjkTFr/QVgRCaxjm0knCNQzNoxxxcw2zO2LJdZA==
dependencies:
es-to-primitive "^1.2.0"
function-bind "^1.1.1"
Expand Down Expand Up @@ -3732,9 +3742,9 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3
integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==

handlebars@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==
version "4.2.0"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.2.0.tgz#57ce8d2175b9bbb3d8b3cf3e4217b1aec8ddcb2e"
integrity sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==
dependencies:
neo-async "^2.6.0"
optimist "^0.6.1"
Expand Down Expand Up @@ -3837,11 +3847,6 @@ hasha@^5.0.0:
is-stream "^1.1.0"
type-fest "^0.3.0"

hoek@4.x.x:
version "4.2.1"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==

home-or-tmp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
Expand Down Expand Up @@ -3887,6 +3892,11 @@ https-proxy-agent@^2.2.1:
agent-base "^4.3.0"
debug "^3.1.0"

humanize@^0.0.9:
version "0.0.9"
resolved "https://registry.yarnpkg.com/humanize/-/humanize-0.0.9.tgz#1994ffaecdfe9c441ed2bdac7452b7bb4c9e41a4"
integrity sha1-GZT/rs3+nEQe0r2sdFK3u0yeQaQ=

husky@^3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.5.tgz#d7db27c346645a8dc52df02aa534a377ad7925e0"
Expand Down Expand Up @@ -4743,9 +4753,10 @@ koa-404-handler@^0.0.2:
resolved "https://registry.yarnpkg.com/koa-404-handler/-/koa-404-handler-0.0.2.tgz#a6b4350099560fb3042db3e57a39094b661bc558"
integrity sha512-F6s31QjJCfDK/amVWQBC9q77x/Fuf5/lspVkiyklrRZ2KzNPk247AEvuVRguyYlGP7mKSHeX+DDwAguP84kcmQ==

"koa-basic-auth@https://github.com/niftylettuce/basic-auth":
version "3.0.0"
resolved "https://github.com/niftylettuce/basic-auth#00d36f982ed53cd861d2d0bf4b25427a1cf167df"
koa-basic-auth@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/koa-basic-auth/-/koa-basic-auth-4.0.0.tgz#7df593771aeb5fe09c6259db206e2e627da64616"
integrity sha512-eV1sGVAizDuFWNpY43VF3Z1ND4PotQZB/igxHNrcJXzXw+Flmj8Uv+4hP9LyNXyvqLJz/X5bmXeMu84AAGD9Jw==
dependencies:
basic-auth "^2.0.0"
tsscmp "^1.0.6"
Expand Down Expand Up @@ -7722,9 +7733,9 @@ run-parallel@^1.1.9:
integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==

rxjs@^6.3.3, rxjs@^6.4.0:
version "6.5.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.2.tgz#2e35ce815cd46d84d02a209fb4e5921e051dbec7"
integrity sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==
version "6.5.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a"
integrity sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==
dependencies:
tslib "^1.9.0"

Expand Down Expand Up @@ -8005,11 +8016,6 @@ split2@^2.0.0:
dependencies:
through2 "^2.0.2"

sprintf-js@^1.0.3:
version "1.1.2"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673"
integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
Expand Down Expand Up @@ -8419,7 +8425,7 @@ to-vfile@^6.0.0:
is-buffer "^2.0.0"
vfile "^4.0.0"

toidentifier@1.0.0:
toidentifier@1.0.0, toidentifier@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
Expand Down Expand Up @@ -8526,14 +8532,6 @@ uid2@0.0.3:
resolved "https://registry.yarnpkg.com/uid2/-/uid2-0.0.3.tgz#483126e11774df2f71b8b639dcd799c376162b82"
integrity sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I=

underscore.string@^3.3.5:
version "3.3.5"
resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.3.5.tgz#fc2ad255b8bd309e239cbc5816fd23a9b7ea4023"
integrity sha512-g+dpmgn+XBneLmXXo+sGlW5xQEt4ErkS3mgeN2GFbremYeMBSJKr9Wf2KJplQVaiPY/f7FN6atosWYNm9ovrYg==
dependencies:
sprintf-js "^1.0.3"
util-deprecate "^1.0.2"

unherit@^1.0.4:
version "1.1.2"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.2.tgz#14f1f397253ee4ec95cec167762e77df83678449"
Expand Down Expand Up @@ -8834,7 +8832,7 @@ user-home@^1.1.1:
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"
integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA=

util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
Expand Down

0 comments on commit c87649d

Please sign in to comment.