hono-request-id
v1.0.0
Published
Request ID middleware for Hono
Downloads
25
Maintainers
Readme
Request ID middleware for Hono
This middleware adds a unique requestId
to each Hono request object. It uses hyperid to generate highly performant, sequential, and unique IDs by default.
Installation
npm i hono hono-request-id
How to Use
Default:
import { Hono } from "hono"
import { requestId } from "hono-request-id"
const app = new Hono()
app.use('*', requestId())
export default app
Custom:
import { Hono } from "hono"
import { requestId } from "hono-request-id"
import crypto from "node:crypto"
const app = new Hono()
app.use('*', requestId(crypto.randomUUID))
export default app
With Pino logger middleware:
import { Hono } from "hono"
import { requestId } from "hono-request-id"
import { pinoLogger } from "hono-pino-logger"
const app = new Hono()
app.use('*', requestId())
app.use('*', pinoLogger())
export default app
Authors
- Maksym Herasymov - https://github.com/maks-herasymov
License
MIT