1.0.0 • Published 1 month ago

hono-request-id v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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

License

MIT

1.0.0

1 month ago