Compare commits
2 Commits
834ae8623a
...
e8c5eb9d85
| Author | SHA1 | Date | |
|---|---|---|---|
| e8c5eb9d85 | |||
| 1576d92efc |
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@because/hype",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"module": "src/index.tsx",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export type HypeProps = {
|
|||
reset?: boolean
|
||||
prettyHTML?: boolean
|
||||
layout?: boolean
|
||||
logging?: boolean
|
||||
}
|
||||
|
||||
type InternalProps = HypeProps & { _isRouter?: boolean }
|
||||
|
|
@ -89,16 +90,18 @@ export class Hype<
|
|||
this.use('/css/*', serveStatic({ root: './src' }))
|
||||
|
||||
// console logging
|
||||
this.use('*', async (c, next) => {
|
||||
if (!SHOW_HTTP_LOG) return await next()
|
||||
if (this.props.logging !== false) {
|
||||
this.use('*', async (c, next) => {
|
||||
if (!SHOW_HTTP_LOG) return await next()
|
||||
|
||||
const start = Date.now()
|
||||
await next()
|
||||
const end = Date.now()
|
||||
const fn = c.res.status < 400 ? color.green : c.res.status < 500 ? color.yellow : color.red
|
||||
const method = c.req.method === 'GET' ? color.cyan(c.req.method) : color.magenta(c.req.method)
|
||||
console.log(fn(`${c.res.status}`), `${color.bold(method)} ${c.req.url} (${end - start}ms)`)
|
||||
})
|
||||
const start = Date.now()
|
||||
await next()
|
||||
const end = Date.now()
|
||||
const fn = c.res.status < 400 ? color.green : c.res.status < 500 ? color.yellow : color.red
|
||||
const method = c.req.method === 'GET' ? color.cyan(c.req.method) : color.magenta(c.req.method)
|
||||
console.log(fn(`${c.res.status}`), `${color.bold(method)} ${c.req.url} (${end - start}ms)`)
|
||||
})
|
||||
}
|
||||
|
||||
// exception handler
|
||||
this.onError((err, c) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user