@stacksjs/bun-router 0.1.16 → 0.1.17
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/cli.js +1 -1
- package/dist/index.js +9 -9
- package/dist/types.d.ts +13 -2
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -832,7 +832,18 @@ export interface UploadedFile {
|
|
|
832
832
|
mimetype: string;
|
|
833
833
|
buffer: ArrayBuffer;
|
|
834
834
|
}
|
|
835
|
-
|
|
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>):
|
|
1240
|
+
(req: RequestFor<TPath>): RouteResult | Promise<RouteResult>;
|
|
1230
1241
|
}
|
|
1231
1242
|
/**
|
|
1232
1243
|
* Strongly typed route definition for specific HTTP methods
|