From 4c34546413bb3d56a9606ba9a32e255ec308e413 Mon Sep 17 00:00:00 2001 From: Imed Jaberi Date: Mon, 4 Nov 2024 05:52:31 +0100 Subject: [PATCH] deps: update http-errors to v2.0.0 (#1486) - https://github.com/jshttp/http-errors/blob/master/HISTORY.md --- __tests__/application/use.test.js | 6 ++-- __tests__/context/throw.test.js | 29 ------------------- package-lock.json | 48 ++++++++++++++++++++----------- package.json | 2 +- 4 files changed, 34 insertions(+), 51 deletions(-) diff --git a/__tests__/application/use.test.js b/__tests__/application/use.test.js index 6f07c7762..e26a62252 100644 --- a/__tests__/application/use.test.js +++ b/__tests__/application/use.test.js @@ -73,11 +73,9 @@ describe('app.use(fn)', () => { it('should catch thrown errors in non-async functions', () => { const app = new Koa() - app.use(ctx => ctx.throw('Not Found', 404)) + app.use(ctx => ctx.throw(404, 'Not Found')) - return request(app.callback()) - .get('/') - .expect(404) + return request(app.callback()).get('/').expect(404) }) it('should throw error for non-function', () => { diff --git a/__tests__/context/throw.test.js b/__tests__/context/throw.test.js index ef98d495d..bc33b1cd5 100644 --- a/__tests__/context/throw.test.js +++ b/__tests__/context/throw.test.js @@ -32,21 +32,6 @@ describe('ctx.throw(err)', () => { }) }) -describe('ctx.throw(err, status)', () => { - it('should throw the error and set .status', () => { - const ctx = context() - const error = new Error('test') - - try { - ctx.throw(error, 422) - } catch (err) { - assert.strictEqual(err.status, 422) - assert.strictEqual(err.message, 'test') - assert.strictEqual(err.expose, true) - } - }) -}) - describe('ctx.throw(status, err)', () => { it('should throw the error and set .status', () => { const ctx = context() @@ -62,20 +47,6 @@ describe('ctx.throw(status, err)', () => { }) }) -describe('ctx.throw(msg, status)', () => { - it('should throw an error', () => { - const ctx = context() - - try { - ctx.throw('name required', 400) - } catch (err) { - assert.strictEqual(err.message, 'name required') - assert.strictEqual(err.status, 400) - assert.strictEqual(err.expose, true) - } - }) -}) - describe('ctx.throw(status, msg)', () => { it('should throw an error', () => { const ctx = context() diff --git a/package-lock.json b/package-lock.json index c6d44a2e5..605b2121c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "escape-html": "^1.0.3", "fresh": "~0.5.2", "http-assert": "^1.3.0", - "http-errors": "^1.6.3", + "http-errors": "^2.0.0", "koa-compose": "^4.1.0", "on-finished": "^2.3.0", "parseurl": "^1.3.2", @@ -2214,7 +2214,15 @@ "node": ">= 0.8" } }, - "node_modules/http-errors": { + "node_modules/http-assert/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-assert/node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", @@ -2229,28 +2237,29 @@ "node": ">= 0.6" } }, - "node_modules/http-errors/node_modules/depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/http-errors/node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" - }, - "node_modules/http-errors/node_modules/statuses": { + "node_modules/http-assert/node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "license": "MIT", "engines": { "node": ">= 0.6" } }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -3591,6 +3600,11 @@ "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", diff --git a/package.json b/package.json index 210a4d050..9b6400ba4 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "escape-html": "^1.0.3", "fresh": "~0.5.2", "http-assert": "^1.3.0", - "http-errors": "^1.6.3", + "http-errors": "^2.0.0", "koa-compose": "^4.1.0", "on-finished": "^2.3.0", "parseurl": "^1.3.2",