import { Server } from "./server/Server"; import { MetadataStorage } from "./metadata/MetadataStorage"; import { ParamHandler } from "./ParamHandler"; export declare type Container = { get(someClass: any): any; }; export declare type JsonErrorHandlerFunction = (error: any, isDebug: boolean, errorOverridingMap: any) => any; export declare type DefaultErrorHandlerFunction = (error: any) => any; /** * Registers controllers and actions in the given server framework. */ export declare class ControllerRunner { private framework; errorOverridingMap: Object; private _container; private _metadataStorage; private _paramHandler; private _isLogErrorsEnabled; private _isStackTraceEnabled; private _jsonErrorHandler; private _defaultErrorHandler; private requireAll; constructor(framework: Server); /** * Sets a container that can be used in your controllers. This allows you to inject services in your * controllers. */ container: Container; /** * Enables console.logging of errors if error occur in handled result. * * @param isEnabled */ isLogErrorsEnabled: boolean; /** * Enables stack trace output if error occur in handled result. * * @param isEnabled */ isStackTraceEnabled: boolean; /** * Sets custom json error handler. * * @param handler */ jsonErrorHandler: JsonErrorHandlerFunction; /** * Sets custom error handler. * * @param handler */ defaultErrorHandler: DefaultErrorHandlerFunction; /** * Sets param handler. * * @param handler */ paramHandler: ParamHandler; /** * Sets metadata storage. * * @param metadataStorage */ metadataStorage: MetadataStorage; /** * Loads all controllers from the given directory * * @param directory Directory where from load controllers * @param recursive Indicates if controllers are in nested directories and thy must be loaded tooo * @param filter Regxep to filter speficif files to load * @param excludeDirs Regxep to exclude some files * @see https://www.npmjs.com/package/require-all */ loadFiles(directory: string, recursive?: boolean, filter?: RegExp, excludeDirs?: RegExp): void; /** * Registers all loaded to the metadata storage controllers and their actions. */ registerAllActions(): ControllerRunner; /** * Registers actions from the given controllers. */ registerActions(classes: Function[]): ControllerRunner; private registerControllerActions(controllerMetadatas); private registerAction(controller, action, responseProperties, params, interceptorMetadatas); private buildActionPath(controller, action); private handleAction(request, response, controllerMetadata, actionMetadata, responsePropertyMetadatas, paramMetadatas, interceptorMetadatas); private getControllerInstance(metadata); private getInterceptorInstancesFromMetadatas(interceptorMetadatas); private getResponseInterceptorInstance(metadata); private isActionMustReturnJson(controllerType, actionOptions); private handleResult(result, options); private handleError(error, options); /** * Handles response error. * * @param error Error to be handled * @param isJson Indicates if response is json-typed or not * @returns {any} */ private processErrorWithErrorHandler(error, isJson); }