Skip to content

SudoSOS Back-end API / internal/controllers / BaseController

Abstract Class: BaseController ​

The BaseController class is responsible for:

  • Storing route definitions.
  • Generating router objects based on the policy.

Extended by ​

Constructors ​

Constructor ​

ts
new BaseController(options): BaseController;

Creates a new controller instance, and generates the router based on its defined policy.

Parameters ​

ParameterType
optionsBaseControllerOptions

Returns ​

BaseController

Options ​

  • The options from which to extract parameters.

Properties ​

PropertyModifierTypeDescription
roleManagerprotectedRoleManagerA reference to the role manager passed in the base controller options.
specificationpublicSwaggerSpecificationA reference to the swagger specification passed in the base controller options.

Methods ​

getPolicy() ​

ts
abstract getPolicy(): Policy;

Gets the policy defined by child classes. This policy includes all routes that the controller accepts, the authorization middleware, and the final handler function for every route.

Returns ​

Policy

The policy of this controller.


getRouter() ​

ts
getRouter(): Router;

Returns ​

Router

the router used by this controller.