Controllers

Getting started

Controllers are responsible to hold a list of functions that will handle URL paths (Request handlers). For example, when a route metadata is defined above the function, Neo will load that object information and seed express about this function.

Differences in Neo

In Neo, controllers are implemented like in MVC Pattern but you additionally receive via depedency injection a ModelRepository which contains the list of loaded models. This may be enabled/disabled at controller initial metadata.

Example of a controller

imports..
@Controller()
class HelloWorld {
    constructor(...) {...}
}

Good practises

MVC stands for Model-View-Controller we need to establish rules for the 3 different groups.

References

Controller (data: IControllerData)

Defines the prefix of this controller Example: www.yourdomain.com/cats/ will have cats as the controller and a route function to handle the / path.