fix: change MultiHandler back to Handlers (#1396)
This commit is contained in:
@@ -192,6 +192,11 @@ export class ServerContext {
|
||||
pattern = String(config.routeOverride);
|
||||
}
|
||||
let { handler } = module as RouteModule;
|
||||
if (!handler && "handlers" in module) {
|
||||
throw new Error(
|
||||
`Found named export "handlers" in ${self} instead of "handler". Did you mean "handler"?`,
|
||||
);
|
||||
}
|
||||
handler ??= {};
|
||||
if (
|
||||
component && typeof handler === "object" && handler.GET === undefined
|
||||
|
||||
+5
-5
@@ -103,19 +103,19 @@ export type Handler<T = any, State = Record<string, unknown>> = (
|
||||
) => Response | Promise<Response>;
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
export type MultiHandler<T = any, State = Record<string, unknown>> = {
|
||||
export type Handlers<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.
|
||||
* @deprecated This type was a short-lived alternative to `Handlers`. Please use `Handlers` instead.
|
||||
*/
|
||||
export type Handlers<T> = MultiHandler<T>;
|
||||
export type MultiHandler<T> = Handlers<T>;
|
||||
|
||||
export interface RouteModule {
|
||||
default?: ComponentType<PageProps>;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
handler?: Handler<any, any> | MultiHandler<any, any>;
|
||||
handler?: Handler<any, any> | Handlers<any, any>;
|
||||
config?: RouteConfig;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ export interface Route<Data = any> {
|
||||
url: string;
|
||||
name: string;
|
||||
component?: ComponentType<PageProps<Data>>;
|
||||
handler: Handler<Data> | MultiHandler<Data>;
|
||||
handler: Handler<Data> | Handlers<Data>;
|
||||
csp: boolean;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user