@ApiControllerObservable
Marks a controller as observable so its CRUD lifecycle emits events to route subscribers. Without this decorator the subscriber registry ignores the controller even if subscribers are registered.
Signature
@ApiControllerObservable()Behavior
- Sets the
CONTROLLER_API_DECORATOR_CONSTANT.OBSERVABLE_METADATA_KEYmetadata flag on the controller class. ApiRouteSubscriberinstances targeting the same entity receivebefore,after, anderrorhooks for each generated route once the flag is present.- Has no runtime cost unless subscribers exist. Unmarked controllers skip the observable pipeline entirely.
Usage example
@Controller("posts")
@ApiController({
entity: PostEntity,
routes: {
/* ... */
},
})
@ApiControllerObservable()
export class PostController {}When to use
- You rely on audit logging, derived DTO changes, or dynamic guard behavior implemented inside
ApiRouteSubscriberclasses. - You need deterministic ordering between multiple subscribers via priorities.
Related resources
Last updated on