@Controller

export declare let Controller: (config: IControllerMetadata) => (Class: any) => any;

Use @Controller decorator to declare controller of application, each controller must be attached to some or multiple modules in application in order to be registered by framework. Each controller must have name because thy are required by router!.

All controllers can be inherited and annotations to inherited class are visible to framework. If you declare providers to controller thy are instantiated together with controller on each request because one request = one controller instance.

Controllers can have filters and each filter.

IControllerMetadata

export interface IControllerMetadata {
    name: string;
    filters?: Array<IFilter>;
    providers?: Array<IProvider | Function>;
}

Usage:

@Controller({
  name: "home",
  filters: [Cache],
  providers: []
})
export class HomeController extends CoreController {

}

In each controller you can inject built in Request api where you have limited api access to http.IncomingMessage and http.ServerResponse.

results matching ""

    No results matching ""