UNPKG

routing-controllers

Version:

Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage for Express / Koa using TypeScript.

148 lines (147 loc) 4.23 kB
import { Action } from '../Action'; import { ActionMetadataArgs } from './args/ActionMetadataArgs'; import { ActionType } from './types/ActionType'; import { ClassTransformOptions } from 'class-transformer'; import { ControllerMetadata } from './ControllerMetadata'; import { InterceptorMetadata } from './InterceptorMetadata'; import { ParamMetadata } from './ParamMetadata'; import { ResponseHandlerMetadata } from './ResponseHandleMetadata'; import { HandlerOptions } from '../decorator-options/HandlerOptions'; import { RoutingControllersOptions } from '../RoutingControllersOptions'; import { UseMetadata } from './UseMetadata'; /** * Action metadata. */ export declare class ActionMetadata { private globalOptions; /** * Action's controller. */ controllerMetadata: ControllerMetadata; /** * Action's parameters. */ params: ParamMetadata[]; /** * Action's use metadatas. */ uses: UseMetadata[]; /** * Action's use interceptors. */ interceptors: InterceptorMetadata[]; /** * Class on which's method this action is attached. */ target: Function; /** * Object's method that will be executed on this action. */ method: string; /** * Action-specific options. */ options: HandlerOptions; /** * Action type represents http method used for the registered route. Can be one of the value defined in ActionTypes * class. */ type: ActionType; /** * Route to be registered for the action. */ route: string | RegExp; /** * Full route to this action (includes controller base route). */ fullRoute: string | RegExp; /** * Indicates if this action uses Body. */ isBodyUsed: boolean; /** * Indicates if this action uses Uploaded File. */ isFileUsed: boolean; /** * Indicates if this action uses Uploaded Files. */ isFilesUsed: boolean; /** * Indicates if controller of this action is json-typed. */ isJsonTyped: boolean; /** * Indicates if this action uses Authorized decorator. */ isAuthorizedUsed: boolean; /** * Class-transformer options for the action response content. */ responseClassTransformOptions: ClassTransformOptions; /** * Http code to be used on undefined action returned content. */ undefinedResultCode: number | Function; /** * Http code to be used on null action returned content. */ nullResultCode: number | Function; /** * Http code to be set on successful response. */ successHttpCode: number; /** * Specifies redirection url for this action. */ redirect: string; /** * Rendered template to be used for this controller action. */ renderedTemplate: string; /** * Response headers to be set. */ headers: { [name: string]: any; }; /** * Extra options used by @Body decorator. */ bodyExtraOptions: any; /** * Roles set by @Authorized decorator. */ authorizedRoles: any[]; /** * Params to be appended to the method call. */ appendParams?: (action: Action) => any[]; /** * Special function that will be called instead of orignal method of the target. */ methodOverride?: (actionMetadata: ActionMetadata, action: Action, params: any[]) => Promise<any> | any; constructor(controllerMetadata: ControllerMetadata, args: ActionMetadataArgs, globalOptions: RoutingControllersOptions); /** * Appends base route to a given regexp route. */ static appendBaseRoute(baseRoute: string, route: RegExp | string): string | RegExp; /** * Builds everything action metadata needs. * Action metadata can be used only after its build. */ build(responseHandlers: ResponseHandlerMetadata[]): void; /** * Calls action method. * Action method is an action defined in a user controller. */ callMethod(params: any[], action: Action): any; /** * Builds full action route. */ private buildFullRoute; /** * Builds action response headers. */ private buildHeaders; }