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, which means its constructor is
auto-wired like any other class: whatever it destructures is resolved for it, from the checker
it holds its contract against to the repository its data() needs to complete a model. Nothing
reads dependencies conditionally, because the container has them.
It is reachable by name. The alias is bound in the container as resource:<name>, prefixed
on purpose: an application is free to bind its own user service, and a resource named user
must not compete for that name.
It activates the module. The blueprint comes with the decorator, so a resource declared this
way is registered and projected without a second gesture, and resource: 'user' on a route
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 an API resource.
Three statements in one, which is why nothing has to be wired by hand:
data()needs to complete a model. Nothing reads dependencies conditionally, because the container has them.resource:<name>, prefixed on purpose: an application is free to bind its ownuserservice, and a resource namedusermust not compete for that name.resource: 'user'on a route resolves to this class.