@biwave/hono
v0.3.1
Published
Biwave Hono middleware — error capture, request-scoped breadcrumbs, context enrichment
Maintainers
Readme
@biwave/hono
Hono framework integration middleware for Biwave error capturing, request context enrichment, and performance tracing (Biwave Pulse).
Features
- Automatic Middleware: Catches unhandled errors thrown inside Hono route handlers.
- Request Isolation: Uses
RequestScope(AsyncLocalStorage) to scope breadcrumbs and trace contexts to individual HTTP requests. - Endpoint Pulse Spans: Measures request execution duration and automatically names spans by matched route pattern (e.g.
/users/:idviahono/route). - Context Enrichment: Captures HTTP method, URL, headers, and request metadata on error.
Installation
# pnpm
pnpm add @biwave/hono @biwave/node @biwave/core hono
# npm
npm install @biwave/hono @biwave/node @biwave/core hono
# yarn
yarn add @biwave/hono @biwave/node @biwave/core honoBasic Usage
import { Hono } from 'hono';
import { init, biwave } from '@biwave/hono';
const app = new Hono();
// Initialize Biwave Hono SDK
const { client, requestScope } = init({
clientId: 'your-client-id',
environment: 'production',
});
// Attach Biwave middleware
app.use('*', biwave(client, requestScope));
app.get('/users/:id', async (c) => {
const userId = c.req.param('id');
if (userId === '0') {
throw new Error('Invalid user ID');
}
return c.json({ id: userId, name: 'Alice' });
});
export default app;License
MIT © Bitech.id
