import { Constructor, Context, ValueOrPromise } from '@loopback/core'; import { ControllerSpec, OperationObject } from '@loopback/openapi-v3'; import { OperationArgs, OperationRetval } from '../types'; import { BaseRoute } from './base-route'; export type ControllerInstance = { [name: string]: any; } & object; /** * A factory function to create controller instances synchronously or * asynchronously */ export type ControllerFactory = (ctx: Context) => ValueOrPromise; /** * Controller class */ export type ControllerClass = Constructor; /** * A route backed by a controller */ export declare class ControllerRoute extends BaseRoute { protected readonly _controllerCtor: ControllerClass; protected readonly _controllerName: string; protected readonly _methodName: string; protected readonly _controllerFactory: ControllerFactory; /** * Construct a controller based route * @param verb - http verb * @param path - http request path * @param spec - OpenAPI operation spec * @param controllerCtor - Controller class * @param controllerFactory - A factory function to create a controller instance * @param methodName - Controller method name, default to `x-operation-name` */ constructor(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass, controllerFactory?: ControllerFactory, methodName?: string); describe(): string; updateBindings(requestContext: Context): void; invokeHandler(requestContext: Context, args: OperationArgs): Promise; } /** * Create a controller factory function for a given binding key * @param key - Binding key */ export declare function createControllerFactoryForBinding(key: string): ControllerFactory; /** * Create a controller factory function for a given class * @param controllerCtor - Controller class */ export declare function createControllerFactoryForClass(controllerCtor: ControllerClass): ControllerFactory; /** * Create a controller factory function for a given instance * @param controllerCtor - Controller instance */ export declare function createControllerFactoryForInstance(controllerInst: T): ControllerFactory; /** * Create routes for a controller with the given spec * @param spec - Controller spec * @param controllerCtor - Controller class * @param controllerFactory - Controller factory */ export declare function createRoutesForController(spec: ControllerSpec, controllerCtor: ControllerClass, controllerFactory?: ControllerFactory): ControllerRoute[]; export declare function joinPath(basePath: string, path: string): string;