rouzer 1.2.3 → 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/server/router.js +7 -0
- package/dist/server/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/server/router.js
CHANGED
|
@@ -73,6 +73,13 @@ class RouterObject extends MiddlewareChain {
|
|
|
73
73
|
continue;
|
|
74
74
|
}
|
|
75
75
|
if (isPreflight) {
|
|
76
|
+
const optionsHandler = handlers[route.name].OPTIONS;
|
|
77
|
+
if (optionsHandler) {
|
|
78
|
+
const response = await optionsHandler(context);
|
|
79
|
+
if (response) {
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
76
83
|
return new Response(null, {
|
|
77
84
|
headers: {
|
|
78
85
|
'Access-Control-Allow-Origin': origin ?? '',
|
package/dist/server/types.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ type InferRouteRequestHandler<TMiddleware extends AnyMiddlewareChain, T, P exten
|
|
|
28
28
|
export type RouteRequestHandlerMap<TRoutes extends Routes = Routes, TMiddleware extends AnyMiddlewareChain = MiddlewareChain> = {
|
|
29
29
|
[K in keyof TRoutes]: {
|
|
30
30
|
[M in keyof TRoutes[K]['methods']]: InferRouteRequestHandler<TMiddleware, TRoutes[K]['methods'][M], TRoutes[K]['path']['source']>;
|
|
31
|
+
} & {
|
|
32
|
+
OPTIONS?: RouteRequestHandler<TMiddleware, {}, void>;
|
|
31
33
|
};
|
|
32
34
|
};
|
|
33
35
|
export {};
|