fix: http-errors ugprade

This commit is contained in:
Alexandre Bodin 2024-04-25 13:36:40 +02:00
parent c5892a9f22
commit 06f017a9dc
5 changed files with 15 additions and 28 deletions

View File

@ -111,6 +111,7 @@
"@types/bcryptjs": "2.4.3",
"@types/configstore": "5.0.1",
"@types/delegates": "1.0.0",
"@types/http-errors": "2.0.4",
"@types/jest": "29.5.2",
"@types/koa": "2.13.4",
"@types/koa-compress": "4.0.3",

View File

@ -23,8 +23,9 @@ const addCustomMethods = (app: Koa) => {
.filter((code) => code >= 400 && code < 600)
.forEach((code) => {
const name = statuses(code);
const camelCasedName = camelCase(name);
app.response[camelCasedName] = function responseCode(message, details = {}) {
app.response[camelCasedName] = function responseCode(message = name, details = {}) {
const httpError = createError(code, message, { details });
const { status, body } = formatHttpError(httpError);
this.status = status;

View File

@ -145,22 +145,17 @@
"esbuild-loader": "^2.21.0",
"esbuild-register": "3.5.0",
"execa": "5.1.1",
"find-root": "1.1.0",
"fork-ts-checker-webpack-plugin": "8.0.0",
"fs-extra": "11.2.0",
"get-latest-version": "5.1.0",
"git-url-parse": "14.0.0",
"glob": "10.3.10",
"html-webpack-plugin": "5.6.0",
"http-errors": "2.0.0",
"https-proxy-agent": "5.0.1",
"inquirer": "8.2.5",
"lodash": "4.17.21",
"mini-css-extract-plugin": "2.7.7",
"nodemon": "3.0.2",
"ora": "5.4.1",
"outdent": "0.8.0",
"package-json": "7.0.0",
"pkg-up": "3.1.0",
"prettier": "3.2.5",
"react": "^18.2.0",
@ -181,10 +176,6 @@
},
"devDependencies": {
"@strapi/ts-zen": "^0.2.0",
"@types/bcryptjs": "2.4.3",
"@types/configstore": "5.0.1",
"@types/delegates": "1.0.0",
"@types/find-root": "1.1.4",
"@types/jest": "29.5.2",
"@types/lodash": "^4.14.191",
"@types/node": "18.19.24",

View File

@ -57,6 +57,7 @@
},
"devDependencies": {
"@strapi/pack-up": "5.0.0",
"@types/http-errors": "2.0.4",
"@types/koa": "2.13.4",
"@types/node": "18.19.24",
"eslint-config-custom": "5.0.0-beta.5",

View File

@ -7276,6 +7276,7 @@ __metadata:
"@types/bcryptjs": "npm:2.4.3"
"@types/configstore": "npm:5.0.1"
"@types/delegates": "npm:1.0.0"
"@types/http-errors": "npm:2.0.4"
"@types/jest": "npm:29.5.2"
"@types/koa": "npm:2.13.4"
"@types/koa-compress": "npm:4.0.3"
@ -8176,10 +8177,6 @@ __metadata:
"@strapi/types": "npm:5.0.0-beta.5"
"@strapi/typescript-utils": "npm:5.0.0-beta.5"
"@strapi/utils": "npm:5.0.0-beta.5"
"@types/bcryptjs": "npm:2.4.3"
"@types/configstore": "npm:5.0.1"
"@types/delegates": "npm:1.0.0"
"@types/find-root": "npm:1.1.4"
"@types/jest": "npm:29.5.2"
"@types/lodash": "npm:^4.14.191"
"@types/node": "npm:18.19.24"
@ -8203,22 +8200,17 @@ __metadata:
esbuild-register: "npm:3.5.0"
eslint-config-custom: "npm:5.0.0-beta.5"
execa: "npm:5.1.1"
find-root: "npm:1.1.0"
fork-ts-checker-webpack-plugin: "npm:8.0.0"
fs-extra: "npm:11.2.0"
get-latest-version: "npm:5.1.0"
git-url-parse: "npm:14.0.0"
glob: "npm:10.3.10"
html-webpack-plugin: "npm:5.6.0"
http-errors: "npm:2.0.0"
https-proxy-agent: "npm:5.0.1"
inquirer: "npm:8.2.5"
lodash: "npm:4.17.21"
mini-css-extract-plugin: "npm:2.7.7"
nodemon: "npm:3.0.2"
ora: "npm:5.4.1"
outdent: "npm:0.8.0"
package-json: "npm:7.0.0"
pkg-up: "npm:3.1.0"
prettier: "npm:3.2.5"
react: "npm:^18.2.0"
@ -8367,6 +8359,7 @@ __metadata:
dependencies:
"@sindresorhus/slugify": "npm:1.1.0"
"@strapi/pack-up": "npm:5.0.0"
"@types/http-errors": "npm:2.0.4"
"@types/koa": "npm:2.13.4"
"@types/node": "npm:18.19.24"
date-fns: "npm:2.30.0"
@ -8970,13 +8963,6 @@ __metadata:
languageName: node
linkType: hard
"@types/find-root@npm:1.1.4":
version: 1.1.4
resolution: "@types/find-root@npm:1.1.4"
checksum: e438c62b3ef3b706d058764797ec5227479ed4be98e9fec5456fb3b9a2096ccd3e35a84c94e2018278e22c651f12ae6ff4d6d7006b09fa5132da3612e2118076
languageName: node
linkType: hard
"@types/fined@npm:*":
version: 1.1.3
resolution: "@types/fined@npm:1.1.3"
@ -9076,6 +9062,13 @@ __metadata:
languageName: node
linkType: hard
"@types/http-errors@npm:2.0.4":
version: 2.0.4
resolution: "@types/http-errors@npm:2.0.4"
checksum: 1f3d7c3b32c7524811a45690881736b3ef741bf9849ae03d32ad1ab7062608454b150a4e7f1351f83d26a418b2d65af9bdc06198f1c079d75578282884c4e8e3
languageName: node
linkType: hard
"@types/inquirer@npm:^6.5.0":
version: 6.5.0
resolution: "@types/inquirer@npm:6.5.0"
@ -16369,7 +16362,7 @@ __metadata:
languageName: node
linkType: hard
"find-root@npm:1.1.0, find-root@npm:^1.1.0":
"find-root@npm:^1.1.0":
version: 1.1.0
resolution: "find-root@npm:1.1.0"
checksum: caa799c976a14925ba7f31ca1a226fe73d3aa270f4f1b623fcfeb1c6e263111db4beb807d8acd31bd4d48d44c343b93688a9288dfbccca27463c36a0301b0bb9
@ -18100,7 +18093,7 @@ __metadata:
languageName: node
linkType: hard
"https-proxy-agent@npm:5.0.1, https-proxy-agent@npm:^5.0.0, https-proxy-agent@npm:^5.0.1":
"https-proxy-agent@npm:^5.0.0, https-proxy-agent@npm:^5.0.1":
version: 5.0.1
resolution: "https-proxy-agent@npm:5.0.1"
dependencies: