Compare commits
No commits in common. "e8c5eb9d854969e4925423095d5c85aef5e7e2cf" and "834ae8623a1bb924dc8010b4030ec26ff730a6f0" have entirely different histories.
e8c5eb9d85
...
834ae8623a
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@because/hype",
|
"name": "@because/hype",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"module": "src/index.tsx",
|
"module": "src/index.tsx",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
@ -26,4 +26,4 @@
|
||||||
"hono": "^4.10.4",
|
"hono": "^4.10.4",
|
||||||
"kleur": "^4.1.5"
|
"kleur": "^4.1.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ export type HypeProps = {
|
||||||
reset?: boolean
|
reset?: boolean
|
||||||
prettyHTML?: boolean
|
prettyHTML?: boolean
|
||||||
layout?: boolean
|
layout?: boolean
|
||||||
logging?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type InternalProps = HypeProps & { _isRouter?: boolean }
|
type InternalProps = HypeProps & { _isRouter?: boolean }
|
||||||
|
|
@ -90,18 +89,16 @@ export class Hype<
|
||||||
this.use('/css/*', serveStatic({ root: './src' }))
|
this.use('/css/*', serveStatic({ root: './src' }))
|
||||||
|
|
||||||
// console logging
|
// console logging
|
||||||
if (this.props.logging !== false) {
|
this.use('*', async (c, next) => {
|
||||||
this.use('*', async (c, next) => {
|
if (!SHOW_HTTP_LOG) return await next()
|
||||||
if (!SHOW_HTTP_LOG) return await next()
|
|
||||||
|
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
await next()
|
await next()
|
||||||
const end = Date.now()
|
const end = Date.now()
|
||||||
const fn = c.res.status < 400 ? color.green : c.res.status < 500 ? color.yellow : color.red
|
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)
|
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)`)
|
console.log(fn(`${c.res.status}`), `${color.bold(method)} ${c.req.url} (${end - start}ms)`)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
// exception handler
|
// exception handler
|
||||||
this.onError((err, c) => {
|
this.onError((err, c) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user