Skip to content

Commit 0d9f062

Browse files
committed
commit 84c89f25b880cf648044e2d0eeb14f9a43e1f2c9 Author: jongleberry <[email protected]> Date: Sat Aug 31 11:02:37 2024 -0700 package-lock++ commit 2c7715c Merge: 5af69c8 b95dfcb Author: jongleberry <[email protected]> Date: Sat Aug 31 10:56:58 2024 -0700 Merge branch 'master' into update-statuses-to-v2.0.0 commit 5af69c8 Author: imed jaberi <[email protected]> Date: Sat Apr 2 14:47:43 2022 +0100 fix tests commit 9af4bb3 Author: imed jaberi <[email protected]> Date: Sat Apr 2 14:43:51 2022 +0100 lint code commit 140be25 Author: imed jaberi <[email protected]> Date: Sat Apr 2 14:42:10 2022 +0100 clean locks ---force commit bc553ec Author: imed jaberi <[email protected]> Date: Sat Apr 2 14:35:12 2022 +0100 clean locks commit 3d7e22a Merge: ff65ef6 f3c67d9 Author: imed jaberi <[email protected]> Date: Sat Apr 2 14:31:30 2022 +0100 resolve conflicts commit ff65ef6 Author: 3imed-jaberi <[email protected]> Date: Tue Jul 14 10:52:50 2020 +0200 deps: use the new statuses api --ctx --response --test commit f565f3b Author: 3imed-jaberi <[email protected]> Date: Tue Jul 14 10:52:31 2020 +0200 deps: use the new statuses api --ctx --response --src commit e8f7609 Author: 3imed-jaberi <[email protected]> Date: Tue Jul 14 10:50:49 2020 +0200 deps: update statuses >> v2.0.0
1 parent c62a0a9 commit 0d9f062

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

__tests__/application/respond.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ describe('app.respond', () => {
335335
describe('with custom status=700', () => {
336336
it('should respond with the associated status message', async () => {
337337
const app = new Koa()
338-
statuses['700'] = 'custom status'
338+
statuses.message['700'] = 'custom status'
339339

340340
app.use(ctx => {
341341
ctx.status = 700

lib/context.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ const proto = module.exports = {
154154
if (err.code === 'ENOENT') statusCode = 404
155155

156156
// default to 500
157-
if (typeof statusCode !== 'number' || !statuses[statusCode]) statusCode = 500
157+
if (typeof statusCode !== 'number' || !statuses.message[statusCode]) statusCode = 500
158158

159159
// respond
160-
const code = statuses[statusCode]
160+
const code = statuses.message[statusCode]
161161
const msg = err.expose ? err.message : code
162162
this.status = err.status = statusCode
163163
this.length = Buffer.byteLength(msg)

lib/response.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = {
8686
assert(code >= 100 && code <= 999, `invalid status code: ${code}`)
8787
this._explicitStatus = true
8888
this.res.statusCode = code
89-
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code]
89+
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses.message[code]
9090
if (this.body && statuses.empty[code]) this.body = null
9191
},
9292

@@ -98,7 +98,7 @@ module.exports = {
9898
*/
9999

100100
get message () {
101-
return this.res.statusMessage || statuses[this.status]
101+
return this.res.statusMessage || statuses.message[this.status]
102102
},
103103

104104
/**

package-lock.json

+15-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"koa-compose": "^4.1.0",
5353
"on-finished": "^2.3.0",
5454
"parseurl": "^1.3.2",
55-
"statuses": "^1.5.0",
55+
"statuses": "^2.0.1",
5656
"type-is": "^1.6.16",
5757
"vary": "^1.1.2"
5858
},

0 commit comments

Comments
 (0)