Three statements in one, which is why nothing has to be wired by hand:
It is a service. The container builds it, as a singleton, so its constructor is auto-wired
like any other class: a repository, a client, a translator, whatever it destructures is resolved
for it. That is what lets a policy depend on the application instead of on constants.
It is reachable by name. The alias is bound as policy:<name>, prefixed on purpose: an
application is free to bind its own service under a plain word, and a declaration named after a
domain concept must not compete for that name.
It activates the module. The blueprint comes with the decorator, so declaring this is the
whole setup, and a route naming it resolves to this class.
Type Parameters
TextendsClassType = ClassType
Parameters
Optionalalias: string
The name a route refers to it by. Defaults to the class name.
Declare a class as a policy.
Three statements in one, which is why nothing has to be wired by hand:
policy:<name>, prefixed on purpose: an application is free to bind its own service under a plain word, and a declaration named after a domain concept must not compete for that name.