Skip to content

Commit

Permalink
⬆️ statuses@2.0.1
Browse files Browse the repository at this point in the history
commit 84c89f25b880cf648044e2d0eeb14f9a43e1f2c9
Author: jongleberry <jonathanrichardong@gmail.com>
Date:   Sat Aug 31 11:02:37 2024 -0700

    package-lock++

commit 2c7715c
Merge: 5af69c8 b95dfcb
Author: jongleberry <jonathanrichardong@gmail.com>
Date:   Sat Aug 31 10:56:58 2024 -0700

    Merge branch 'master' into update-statuses-to-v2.0.0

commit 5af69c8
Author: imed jaberi <imed.jaberi@hotmail.fr>
Date:   Sat Apr 2 14:47:43 2022 +0100

    fix tests

commit 9af4bb3
Author: imed jaberi <imed.jaberi@hotmail.fr>
Date:   Sat Apr 2 14:43:51 2022 +0100

    lint code

commit 140be25
Author: imed jaberi <imed.jaberi@hotmail.fr>
Date:   Sat Apr 2 14:42:10 2022 +0100

    clean locks ---force

commit bc553ec
Author: imed jaberi <imed.jaberi@hotmail.fr>
Date:   Sat Apr 2 14:35:12 2022 +0100

    clean locks

commit 3d7e22a
Merge: ff65ef6 f3c67d9
Author: imed jaberi <imed.jaberi@hotmail.fr>
Date:   Sat Apr 2 14:31:30 2022 +0100

    resolve conflicts

commit ff65ef6
Author: 3imed-jaberi <imed_jebari@hotmail.fr>
Date:   Tue Jul 14 10:52:50 2020 +0200

     deps: use the new statuses api --ctx --response --test

commit f565f3b
Author: 3imed-jaberi <imed_jebari@hotmail.fr>
Date:   Tue Jul 14 10:52:31 2020 +0200

     deps: use the new statuses api --ctx --response --src

commit e8f7609
Author: 3imed-jaberi <imed_jebari@hotmail.fr>
Date:   Tue Jul 14 10:50:49 2020 +0200

     deps: update statuses >> v2.0.0
  • Loading branch information
jonathanong committed Aug 31, 2024
1 parent c62a0a9 commit 0d9f062
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion __tests__/application/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ describe('app.respond', () => {
describe('with custom status=700', () => {
it('should respond with the associated status message', async () => {
const app = new Koa()
statuses['700'] = 'custom status'
statuses.message['700'] = 'custom status'

app.use(ctx => {
ctx.status = 700
Expand Down
4 changes: 2 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ const proto = module.exports = {
if (err.code === 'ENOENT') statusCode = 404

// default to 500
if (typeof statusCode !== 'number' || !statuses[statusCode]) statusCode = 500
if (typeof statusCode !== 'number' || !statuses.message[statusCode]) statusCode = 500

// respond
const code = statuses[statusCode]
const code = statuses.message[statusCode]
const msg = err.expose ? err.message : code
this.status = err.status = statusCode
this.length = Buffer.byteLength(msg)
Expand Down
4 changes: 2 additions & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
assert(code >= 100 && code <= 999, `invalid status code: ${code}`)
this._explicitStatus = true
this.res.statusCode = code
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code]
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses.message[code]
if (this.body && statuses.empty[code]) this.body = null
},

Expand All @@ -98,7 +98,7 @@ module.exports = {
*/

get message () {
return this.res.statusMessage || statuses[this.status]
return this.res.statusMessage || statuses.message[this.status]
},

/**
Expand Down
20 changes: 15 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"koa-compose": "^4.1.0",
"on-finished": "^2.3.0",
"parseurl": "^1.3.2",
"statuses": "^1.5.0",
"statuses": "^2.0.1",
"type-is": "^1.6.16",
"vary": "^1.1.2"
},
Expand Down

0 comments on commit 0d9f062

Please sign in to comment.