import { MiddlewareParameter, Constructor, IRouterConfigState, ClassOrFunctionReturning } from './state-util'; import { HttpVerb } from './http-verbs'; import { STATE, IS_CONTROLLER_BUILDER } from './symbols'; /** * Method builder options. */ export interface IMethodBuilderOpts { before?: MiddlewareParameter; after?: MiddlewareParameter; } /** * Verb builder function. */ export declare type VerbBuilderFunction = (path: string, method: keyof T, opts?: IMethodBuilderOpts) => IAwilixControllerBuilder; /** * Fluid router builder. */ export interface IAwilixControllerBuilder { [STATE]: IRouterConfigState; [IS_CONTROLLER_BUILDER]: boolean; target: Constructor | Function; get: VerbBuilderFunction; post: VerbBuilderFunction; put: VerbBuilderFunction; patch: VerbBuilderFunction; delete: VerbBuilderFunction; head: VerbBuilderFunction; options: VerbBuilderFunction; connect: VerbBuilderFunction; all: VerbBuilderFunction; verbs(verbs: Array, path: string, method: keyof T, opts?: IMethodBuilderOpts): this; prefix(path: string): this; before(value: MiddlewareParameter): this; after(value: MiddlewareParameter): this; } /** * Configures routing config for a class or function to be invoked by a router. * * @example * const api = ({ todoService }) => ({ * find: (ctx) => { ... } * }) * * export default createController(api) * .prefix('/todos') * .before(bodyParser()) * .get('/', 'find') * .get('/:id', 'get') * .post('/:id', 'create', { * before: [authenticate()], * }) * .patch('/:id', 'update', { * before: [authenticate()] * }) */ export declare function createController(ClassOrFunction: ClassOrFunctionReturning): IAwilixControllerBuilder; /** * Creates a builder from existing state. * This is used internally, but exported for convenience. * * @param ClassOrFunction The target to invoke. * @param state Existing state to continue building on. */ export declare function createControllerFromState(ClassOrFunction: Constructor | Function, state: IRouterConfigState): IAwilixControllerBuilder;