hono-request-id
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i hono-request-id

Weekly Downloads

16

Version

1.0.0

License

MIT

Unpacked Size

3.05 kB

Total Files

5

Last publish

Collaborators

  • maks-herasymov