/** * @module server */ /** End Typedoc Module Declaration */ import { Server, HttpMethod } from '../servers/abstract.server'; import { Injector } from '@angular/core'; import { Logger } from '../../common/services/logger.service'; import { InjectableMiddlewareFactory } from '../middleware/index'; import { RegistryEntityStatic, RegistryEntity } from '../../common/registry/entityRegistry'; import { ControllerMetadata } from '../registry/decorators'; export interface MethodDefinition { method: HttpMethod; route: string; } export interface MethodDictionary { [methodSignature: string]: MethodDefinition; } export declare type MiddlewareLocation = 'before' | 'after'; export interface ControllerConstructor extends Function { constructor: ControllerStatic; } export interface ControllerStatic extends RegistryEntityStatic { new (server: Server, logger: Logger): T; prototype: T; registerMiddleware(location: MiddlewareLocation, middlewareFactories: InjectableMiddlewareFactory[], methodSignature?: string): void; } /** * Abstract controller that all controllers *must* extend from. The [[ControllerBootstrapper]] * relies on the interface provided by this class to invoke registration of routes and middleware */ export declare abstract class AbstractController extends RegistryEntity { static __metadataDefault: ControllerMetadata; protected actionMethods: Map; /** Current controller instance */ protected logger: Logger; /** Instance of injector used for the registration of @Injectable middleware */ private injector; constructor(logger: Logger); /** * Register a reference to the current injector, this is not injected directly as there is likely * to be a better way to get an injector reference for decorators * @see https://github.com/angular/angular/issues/4112#issuecomment-175200243 * @param injector * @returns {AbstractController} */ registerInjector(injector: Injector): this; /** * Register an action. This is used by the @Route() decorator, but can also be called directly * for custom route registration * @param methodSignature * @param method * @param route */ registerActionMethod(methodSignature: string, method: HttpMethod, route: string): void; /** * Middleware registration. This is used by the @Before & @After decorators to assign middleware * to the controller method instance. * @param location * @param middlewareFactories * @param methodSignature * @returns void */ static registerMiddleware(location: MiddlewareLocation, middlewareFactories: InjectableMiddlewareFactory[], methodSignature?: string): void; /** * Register all routes defined in this controller (or any extending instances) with the server * @returns {AbstractController} */ registerRoutes(server: Server): this; }