mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 10:51:01 +00:00
15 lines
396 B
TypeScript
15 lines
396 B
TypeScript
|
import type { Context } from '../../context.ts'
|
||
|
import type { Next } from '../../hono.ts'
|
||
|
|
||
|
type prettyOptions = {
|
||
|
space: number
|
||
|
}
|
||
|
|
||
|
export const prettyJSON = (options: prettyOptions = { space: 2 }) => {
|
||
|
return async (c: Context, next: Next) => {
|
||
|
const pretty = c.req.query('pretty') || c.req.query('pretty') === '' ? true : false
|
||
|
c.pretty(pretty, options.space)
|
||
|
await next()
|
||
|
}
|
||
|
}
|