@basaltkit/hono 1.2.1 → 1.3.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.
package/dist/index.d.ts CHANGED
@@ -10,6 +10,13 @@ export interface HonoPluginOptions {
10
10
  routes?: BasaltRoute[];
11
11
  /** Bring your own Hono app; otherwise a fresh one is created. */
12
12
  app?: Hono<any>;
13
+ /**
14
+ * Serve the neutral JSON body (`NOT_FOUND_RESPONSE` from @basaltkit/http)
15
+ * for unmatched routes, identical across all adapters, instead of Hono's
16
+ * text default. Default: true. An app calling `hono.notFound(…)` later
17
+ * still wins (Hono keeps the last handler); pass false to opt out entirely.
18
+ */
19
+ notFound?: boolean;
13
20
  /**
14
21
  * Maximum request body size in bytes. A request whose `Content-Length`
15
22
  * exceeds this is rejected with 413 before the body is read — Hono/edge has
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Container, createToken, definePlugin, ensureMetadata } from '@basaltkit/core';
2
- import { HttpServerCollector, HTTP_SERVER, runRoute, toErrorResponse, isSseResponse, sseProducerOf, driveSse, SSE_HEADERS, } from '@basaltkit/http';
2
+ import { NOT_FOUND_RESPONSE, HttpServerCollector, HTTP_SERVER, runRoute, toErrorResponse, isSseResponse, sseProducerOf, driveSse, SSE_HEADERS, } from '@basaltkit/http';
3
3
  import { Hono } from 'hono';
4
4
  export const HONO = createToken('hono');
5
5
  /** Default maximum request body size (1 MiB) — override via honoPlugin({ bodyLimit }). */
@@ -182,6 +182,10 @@ export function honoPlugin(options = {}) {
182
182
  return undefined;
183
183
  });
184
184
  registerRoutes(app, routes, container, enrichers, guards);
185
+ // Neutral JSON 404 (an app's own later `notFound` call replaces it).
186
+ if (options.notFound !== false) {
187
+ app.notFound((context) => context.json(NOT_FOUND_RESPONSE, 404));
188
+ }
185
189
  for (const { method, url, handler } of collector.extraRoutes) {
186
190
  app.on(method, url, async (context) => {
187
191
  const reply = new HonoReply(context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basaltkit/hono",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Hono adapter for Basalt: run the same typed routes, enrichers and guards on Hono (Node, Bun, Deno, edge) as on Fastify or Express.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "dependencies": {
17
17
  "@basaltkit/core": "^1.1.2",
18
- "@basaltkit/http": "^1.9.1"
18
+ "@basaltkit/http": "^1.10.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "hono": "^4.0.0"