Skip to content

Commit

Permalink
refactor(logger): remove unreachable cases. Response accepts 200-599
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Oct 31, 2024
1 parent 9e9e900 commit a95bcce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
6 changes: 0 additions & 6 deletions src/middleware/logger/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ describe('Logger by Middleware', () => {
Location: '/empty',
})
})
app.get('/1xx', (c) => {
return c.text('', 100)
})
app.get('/5xx', (c) => {
return c.text('', 511)
})
app.get('/7xx', (c) => {
return c.text('', 777 as never)
})
})

it('Log status 200 with empty body', async () => {
Expand Down
10 changes: 3 additions & 7 deletions src/middleware/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ const colorStatus = (status: number) => {
return `${status}`
}
switch ((status / 100) | 0) {
case 7: // magenta = ???
return `\x1b[35m${status}\x1b[0m`
case 5: // red = error
return `\x1b[31m${status}\x1b[0m`
case 4: // yellow = warning
return `\x1b[33m${status}\x1b[0m`
case 3: // cyan = redirect
return `\x1b[36m${status}\x1b[0m`
case 2:
case 1: // green = success
case 2: // green = success
return `\x1b[32m${status}\x1b[0m`
case 4:
case 0: // yellow = warning
return `\x1b[33m${status}\x1b[0m`
}
}

Expand Down

0 comments on commit a95bcce

Please sign in to comment.