UNPKG

@feathersjs/hooks

Version:

Async middleware for JavaScript and TypeScript

14 lines (13 loc) 960 B
import { HookContext } from './base.js'; export type RegularMiddleware<T extends HookContext = any> = (context: T) => Promise<any> | any; export interface RegularHookMap { before?: RegularMiddleware[]; after?: RegularMiddleware[]; error?: RegularMiddleware[]; } export declare const runHook: (hook: RegularMiddleware, context: any, type?: string) => Promise<void>; export declare const runHooks: (hooks: RegularMiddleware[]) => (context: any) => Promise<any>; export declare function fromBeforeHook(hook: RegularMiddleware): (context: any, next: any) => Promise<void>; export declare function fromAfterHook(hook: RegularMiddleware): (context: any, next: any) => any; export declare function fromErrorHook(hook: RegularMiddleware): (context: any, next: any) => any; export declare function collect({ before, after, error, }: RegularHookMap): (this: any, context: any, next?: import("./compose.js").AsyncMiddleware<any> | undefined) => Promise<any>;