diff --git a/src/Router/Middleware.ts b/src/Router/Middleware.ts index 1e27bfb..31f2047 100644 --- a/src/Router/Middleware.ts +++ b/src/Router/Middleware.ts @@ -13,7 +13,7 @@ import { Pattern } from './Pattern'; * @param router The current router instance. * @return The Response instance. */ -export type MiddlewareBeforeHandler = (request: Request, response: Response, params: RequestParams, router: Router) => Response|Promise|void; +export type MiddlewareBeforeHandler = (request: Request, response: Response, params: RequestParams, router: Router) => Response|void|Promise; /** * The signature of middleware handler to invoke after routing. @@ -23,7 +23,7 @@ export type MiddlewareBeforeHandler = (request: Request, response: Response, par * @param router The current router instance. * @return The Response instance. */ -export type MiddlewareAfterHandler = (request: Readonly, response: Response, params: RequestParams, router: Router) => Response|Promise; +export type MiddlewareAfterHandler = (request: Readonly, response: Response, params: RequestParams, router: Router) => Response|void|Promise; /** * The interface of a middleware rule. diff --git a/src/Router/Route.ts b/src/Router/Route.ts index f499006..2e0bbea 100644 --- a/src/Router/Route.ts +++ b/src/Router/Route.ts @@ -12,7 +12,7 @@ import { Pattern } from './Pattern'; * @param router The current router instance. * @return The next Response instance. */ -export type NextHandler = (request: Request, response: Response, router: Router) => Response|Promise; +export type NextHandler = (request: Request, response: Response, router: Router) => Response|void|Promise; /** * The signature of a Route handler method. @@ -22,7 +22,7 @@ export type NextHandler = (request: Request, response: Response, router: Router) * @param router The current router instance. * @return The very same input Response instance or a new one. */ -export type RouteHandler = (request: Readonly, response: Readonly, next: NextHandler, router: Router) => Response|string|Promise; +export type RouteHandler = (request: Readonly, response: Readonly, next: NextHandler, router: Router) => Response|string|void|Promise; /** * The interface of a route rule. diff --git a/src/Router/Router.ts b/src/Router/Router.ts index 3e00c7e..5f6677c 100644 --- a/src/Router/Router.ts +++ b/src/Router/Router.ts @@ -222,7 +222,7 @@ export class Router extends Factory.Emitter { ); try { - response = await starter(request, response, this); + response = (await starter(request, response, this)) ?? response; } catch (error) { request.reject(error as Error); throw error; diff --git a/src/Router/State.ts b/src/Router/State.ts index 2254126..4f66e3c 100644 --- a/src/Router/State.ts +++ b/src/Router/State.ts @@ -9,6 +9,7 @@ export interface State { url: string; index: number; title: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any store: any; request: Request; response?: Response;