@stacksjs/bun-router 0.1.16 → 0.1.18

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.
@@ -70,9 +70,6 @@ export interface ResponseFactory {
70
70
  serverError: (message?: string) => Response;
71
71
  tooManyRequests: (message?: string, retryAfter?: number) => Response;
72
72
  }
73
- /**
74
- * Response factory with common response helpers
75
- */
76
73
  export declare const response: ResponseFactory;
77
74
  /**
78
75
  * Fluent response builder
package/dist/types.d.ts CHANGED
@@ -832,7 +832,18 @@ export interface UploadedFile {
832
832
  mimetype: string;
833
833
  buffer: ArrayBuffer;
834
834
  }
835
- export type RouteHandler = (_req: EnhancedRequest) => Response | Promise<Response>;
835
+ /**
836
+ * What a handler may return.
837
+ *
838
+ * The resolver has always wrapped a plain value - `wrapResponse` turns a
839
+ * string, a number, a boolean, bytes, a stream, or an object into a Response,
840
+ * and the handler-resolver documents that as a supported shape. The types said
841
+ * otherwise, so the documented idiom did not compile and every example that
842
+ * returns an object had to be cast. Widening this is safe for existing
843
+ * handlers: a `Response` is still a `RouteResult`.
844
+ */
845
+ export type RouteResult = Response | string | number | boolean | ArrayBuffer | Uint8Array | ReadableStream | object | null | undefined;
846
+ export type RouteHandler = (_req: EnhancedRequest) => RouteResult | Promise<RouteResult>;
836
847
  /**
837
848
  * Interface for handling route actions.
838
849
  * All action handlers must implement this interface.
@@ -1226,7 +1237,7 @@ export type RequestFor<TPath extends string> = Omit<EnhancedRequest, 'params'> &
1226
1237
  params: ExtractRouteParams<TPath>;
1227
1238
  };
1228
1239
  export interface TypedRouteHandler<TPath extends string> {
1229
- (req: RequestFor<TPath>): Response | Promise<Response>;
1240
+ (req: RequestFor<TPath>): RouteResult | Promise<RouteResult>;
1230
1241
  }
1231
1242
  /**
1232
1243
  * Strongly typed route definition for specific HTTP methods
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/bun-router",
3
3
  "type": "module",
4
- "version": "0.1.16",
4
+ "version": "0.1.18",
5
5
  "description": "A fast, type-safe router for Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",