refactor: changed Handlers type to MultiHandler (#1360)

This commit is contained in:
Aushwin
2023-06-28 12:52:48 +00:00
committed by GitHub
parent a30c6bdf5c
commit 851f8d60aa
26 changed files with 64 additions and 58 deletions
+1
View File
@@ -22,6 +22,7 @@ export type {
Handlers,
MiddlewareHandler,
MiddlewareHandlerContext,
MultiHandler,
PageProps,
Plugin,
PluginAsyncRenderContext,
+8 -3
View File
@@ -102,14 +102,19 @@ export type Handler<T = any, State = Record<string, unknown>> = (
) => Response | Promise<Response>;
// deno-lint-ignore no-explicit-any
export type Handlers<T = any, State = Record<string, unknown>> = {
export type MultiHandler<T = any, State = Record<string, unknown>> = {
[K in router.KnownMethod]?: Handler<T, State>;
};
/**
* @deprecated This type has been deprecated and is replaced with MultiHandler type.
*/
export type Handlers<T> = MultiHandler<T>;
export interface RouteModule {
default?: ComponentType<PageProps>;
// deno-lint-ignore no-explicit-any
handler?: Handler<any, any> | Handlers<any, any>;
handler?: Handler<any, any> | MultiHandler<any, any>;
config?: RouteConfig;
}
@@ -119,7 +124,7 @@ export interface Route<Data = any> {
url: string;
name: string;
component?: ComponentType<PageProps<Data>>;
handler: Handler<Data> | Handlers<Data>;
handler: Handler<Data> | MultiHandler<Data>;
csp: boolean;
}