|
|
@@ -1,4 +1,5 @@
|
|
|
import {Callable} from '../types.js';
|
|
|
+import {RequestContext} from '../request-context.js';
|
|
|
import {DebuggableService} from '../debuggable-service.js';
|
|
|
|
|
|
/**
|
|
|
@@ -17,12 +18,38 @@ export type HookType = (typeof HookType)[keyof typeof HookType];
|
|
|
/**
|
|
|
* Router hook.
|
|
|
*/
|
|
|
-export type RouterHook<T = unknown> = Callable<T>;
|
|
|
+export type RouterHook = Callable;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Pre handler hook.
|
|
|
+ */
|
|
|
+export type PreHandlerHook = (ctx: RequestContext) => unknown;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Post handler hook.
|
|
|
+ */
|
|
|
+export type PostHandlerHook = (ctx: RequestContext, data: unknown) => unknown;
|
|
|
|
|
|
/**
|
|
|
* Hook registry.
|
|
|
*/
|
|
|
export declare class HookRegistry extends DebuggableService {
|
|
|
+ /**
|
|
|
+ * Add hook.
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param hook
|
|
|
+ */
|
|
|
+ addHook(type: typeof HookType.PRE_HANDLER, hook: PreHandlerHook): this;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Add hook.
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param hook
|
|
|
+ */
|
|
|
+ addHook(type: typeof HookType.POST_HANDLER, hook: PostHandlerHook): this;
|
|
|
+
|
|
|
/**
|
|
|
* Add hook.
|
|
|
*
|