@nimbus-cqrs/hono 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +26 -22
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -13,7 +13,7 @@ Refer to the [Nimbus main repository](https://github.com/overlap-dev/Nimbus) or
13
13
 
14
14
  ```bash
15
15
  # Deno
16
- deno add jsr:@nimbus-cqrs/hono
16
+ deno add npm:@nimbus-cqrs/hono
17
17
 
18
18
  # NPM
19
19
  npm install @nimbus-cqrs/hono
@@ -33,15 +33,15 @@ For detailed documentation, please refer to the [Nimbus documentation](https://n
33
33
  A typical setup wires up all three pieces together: the correlation ID middleware first (so the logger and downstream handlers can read it), the logger second, your routes, and the error handler last.
34
34
 
35
35
  ```typescript
36
- import { Hono } from 'hono';
37
- import { correlationId, handleError, logger } from '@nimbus-cqrs/hono';
36
+ import { Hono } from "hono";
37
+ import { correlationId, handleError, logger } from "@nimbus-cqrs/hono";
38
38
 
39
39
  const app = new Hono();
40
40
 
41
41
  app.use(correlationId());
42
42
  app.use(logger({ enableTracing: true }));
43
43
 
44
- app.get('/hello', (c) => c.json({ hello: 'world' }));
44
+ app.get("/hello", (c) => c.json({ hello: "world" }));
45
45
 
46
46
  app.onError(handleError);
47
47
 
@@ -53,14 +53,14 @@ export default app;
53
53
  `correlationId()` is a Hono middleware that ensures every request carries a stable correlation ID. It reads one from the incoming headers (`x-correlation-id`, `x-request-id` or `request-id`, in that order), or generates a fresh [ULID](https://github.com/ulid/spec) if none is present. The ID is stored on the Hono context and — by default — echoed back in the response as `x-correlation-id`.
54
54
 
55
55
  ```typescript
56
- import { Hono } from 'hono';
57
- import { correlationId, getCorrelationId } from '@nimbus-cqrs/hono';
56
+ import { Hono } from "hono";
57
+ import { correlationId, getCorrelationId } from "@nimbus-cqrs/hono";
58
58
 
59
59
  const app = new Hono();
60
60
 
61
61
  app.use(correlationId());
62
62
 
63
- app.get('/whoami', (c) => {
63
+ app.get("/whoami", (c) => {
64
64
  const cid = getCorrelationId(c);
65
65
  return c.json({ correlationId: cid });
66
66
  });
@@ -71,10 +71,12 @@ Use `getCorrelationId(c)` anywhere you have a Hono context (route handlers, down
71
71
  You can opt out of the response header or rename it:
72
72
 
73
73
  ```typescript
74
- app.use(correlationId({
75
- addToResponseHeaders: true,
76
- responseHeaderName: 'x-trace-id',
77
- }));
74
+ app.use(
75
+ correlationId({
76
+ addToResponseHeaders: true,
77
+ responseHeaderName: "x-trace-id",
78
+ })
79
+ );
78
80
  ```
79
81
 
80
82
  ## logger
@@ -89,16 +91,18 @@ When `enableTracing` is on (default), it also:
89
91
  - marks the span as errored on `5xx`/`4xx` responses or thrown exceptions.
90
92
 
91
93
  ```typescript
92
- import { Hono } from 'hono';
93
- import { correlationId, logger } from '@nimbus-cqrs/hono';
94
+ import { Hono } from "hono";
95
+ import { correlationId, logger } from "@nimbus-cqrs/hono";
94
96
 
95
97
  const app = new Hono();
96
98
 
97
99
  app.use(correlationId());
98
- app.use(logger({
99
- enableTracing: true,
100
- tracerName: 'api',
101
- }));
100
+ app.use(
101
+ logger({
102
+ enableTracing: true,
103
+ tracerName: "api",
104
+ })
105
+ );
102
106
  ```
103
107
 
104
108
  Set `enableTracing: false` if you only want the request/response log lines and don't run an OpenTelemetry SDK.
@@ -108,14 +112,14 @@ Set `enableTracing: false` if you only want the request/response log lines and d
108
112
  `handleError` is a drop-in handler for `app.onError(...)`. It maps any `Exception` thrown anywhere in the request pipeline (a Nimbus core exception or one of its subclasses such as `NotFoundException`, `InvalidInputException`, `UnauthorizedException`, `ForbiddenException`, …) to a JSON response using the exception's `statusCode`, `name`, `message` and optional `details`. Anything else falls back to a generic `500 INTERNAL_SERVER_ERROR` and is logged at `critical` level.
109
113
 
110
114
  ```typescript
111
- import { Hono } from 'hono';
112
- import { NotFoundException } from '@nimbus-cqrs/core';
113
- import { handleError } from '@nimbus-cqrs/hono';
115
+ import { Hono } from "hono";
116
+ import { NotFoundException } from "@nimbus-cqrs/core";
117
+ import { handleError } from "@nimbus-cqrs/hono";
114
118
 
115
119
  const app = new Hono();
116
120
 
117
- app.get('/todos/:id', (c) => {
118
- throw new NotFoundException('Todo not found', { id: c.req.param('id') });
121
+ app.get("/todos/:id", (c) => {
122
+ throw new NotFoundException("Todo not found", { id: c.req.param("id") });
119
123
  });
120
124
 
121
125
  app.onError(handleError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbus-cqrs/hono",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Simplify Event-Driven Applications - Hono integration for the Nimbus framework.",
5
5
  "keywords": [
6
6
  "nimbus",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@opentelemetry/api": "^1.9.1",
38
- "hono": "^4.12.14",
39
- "zod": "^4.3.6",
40
- "@nimbus-cqrs/core": "^2.1.1"
38
+ "hono": "^4.12.27",
39
+ "zod": "^4.4.3",
40
+ "@nimbus-cqrs/core": "^2.2.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.0.0"