Skip to content

Commit 4cfa6ce

Browse files
committed
去掉chalk
1 parent 9ca73f7 commit 4cfa6ce

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

lib/app.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const http = require('http')
22
const Koa = require('koa')
33
const koaBody = require('koa-body')
44
const util = require('util')
5-
const chalk = require('chalk')
65

76
const router = require('./router')
87
const logger = require('./logger')
@@ -27,32 +26,22 @@ class App {
2726
logger.log(
2827
request.ip,
2928
request.protocol,
30-
chalk.black(chalk.bgBlue(request.method)),
31-
chalk.black(chalk.bgCyan(request.url)),
32-
chalk.gray('<<'),
29+
request.method,
30+
request.url,
31+
'<<',
3332
request.type,
34-
chalk.gray(tldr(request.body)),
33+
tldr(request.body),
3534
)
3635
await next()
37-
let statusColor
38-
if (response.status >= 200 && response.status < 300) {
39-
statusColor = 'bgGreen'
40-
} else if (response.status >= 300 && response.status < 400) {
41-
statusColor = 'bgYellow'
42-
} else if (response.status >= 400 && response.status < 500) {
43-
statusColor = 'bgYellow'
44-
} else if (response.status >= 500) {
45-
statusColor = 'bgRed'
46-
}
4736
logger.log(
4837
request.ip,
4938
request.protocol,
50-
chalk.black(chalk.bgBlue(request.method)),
51-
chalk.black(chalk.bgCyan(request.url)),
52-
chalk.gray('>>'),
39+
request.method,
40+
request.url,
41+
'>>',
5342
response.type,
54-
chalk.black(chalk[statusColor](response.status)),
55-
chalk.gray(tldr(response.body)),
43+
response.status,
44+
tldr(response.body),
5645
)
5746
}
5847
})())

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"dependencies": {
1414
"@z-ivan/console": "^1.1.0",
15-
"chalk": "^5.2.0",
1615
"koa": "^2.14.1",
1716
"koa-body": "^6.0.1",
1817
"koa-router": "^12.0.0",

0 commit comments

Comments
 (0)