Skip to Content
DocsNestJS CRUD AutomatorAPI ReferenceDecoratorsSubscriber DecoratorsSubscriber Decorators

Subscriber Decorators

Subscriber decorators register injectable classes that intercept controller or service lifecycles. They coordinate with @ApiControllerObservable and @ApiServiceObservable to emit before/after/error hooks.

Available decorators

DecoratorPurposeReference
@ApiFunctionSubscriberSubscribes to service-level events (create, update, delete, get*, etc.) and can mutate DTOs or results./docs/nestjs-crud-automator/api-reference/decorators/api-subscriber/api-function-subscriber
@ApiRouteSubscriberSubscribes to controller route lifecycle events (before/after/error for CRUD endpoints)./docs/nestjs-crud-automator/api-reference/decorators/api-subscriber/api-route-subscriber

Usage checklist

  1. Mark the corresponding controller or service as observable.
  2. Extend the appropriate subscriber base class and implement lifecycle handlers.
  3. Decorate the subscriber with the relevant decorator and optionally assign a priority to control execution order.
Last updated on