xTaskjs 1.0 is live: role-based accounts, documentation, and a customizable interface.

Decorators

Reference for every public xtaskjs decorator across routing, lifecycle, DI, security, persistence, cache, scheduling, and queues.

This page lists the framework decorator surface exposed by the upstream packages, grouped by use case and labeled with the package each decorator comes from, plus small usage examples you can adapt directly.

116 decorators across 16 groups

Grouped by type

Routing, lifecycle, DI, security, TypeORM, mailer, cache, scheduler, and queue decorators are separated so similar APIs stay together.

Package-aware

Every entry shows the package and upstream source path where the decorator lives.

Example-driven

Each decorator includes a short snippet drawn from the same patterns used in xtaskjs samples and this site.

Catalog

Decorator groups by use case

Decorator Group

HTTP Routing And Pipelines

Route declaration and request-pipeline decorators exported by @xtaskjs/common. These are the core HTTP building blocks used by controllers in every sample.

13 decorators

Decorator Group

Lifecycle Runners And Events

Lifecycle decorators from @xtaskjs/common used to run startup logic, CLI tasks, and event handlers inside the application lifecycle.

3 decorators

Decorator Group

Core DI And Components

Dependency-injection and component decorators from @xtaskjs/core. These mark providers for container discovery and select named bindings for injection.

8 decorators

Decorator Group

Security And Authorization

Authentication, authorization, strategy, and injector decorators exported by @xtaskjs/security. These layer on top of @xtaskjs/common route metadata.

10 decorators

Decorator Group

Persistence And Repositories

TypeORM registration and injection decorators exported by @xtaskjs/typeorm. These bind datasources and repositories into the same DI container.

5 decorators

Decorator Group

CQRS Buses, Handlers, And Projections

CQRS configuration, handler, projection, idempotency, and injector decorators exported by @xtaskjs/cqrs. These connect command, query, and event flows to the xtaskjs container and read or write datasource aliases.

16 decorators

Decorator Group

Event Sourcing And Stored Events

Configuration, aggregate, subscriber, and injector decorators exported by @xtaskjs/event-source. These wire aggregate metadata, event appliers, repositories, and stored-event subscribers into the xtaskjs lifecycle.

9 decorators

Decorator Group

Mailer Templates And Delivery

Mailer decorators exported by @xtaskjs/mailer. These register transports and templates and inject delivery services into DI-managed classes.

5 decorators

Decorator Group

Internationalization And Locale Resolution

Configuration and injector decorators exported by @xtaskjs/internationalization. These register locale behavior and expose translation services inside DI-managed classes.

7 decorators

Decorator Group

Value Objects And DTO Transformation

DTO-oriented decorators from @xtaskjs/value-objects that turn raw request fields into normalized domain wrappers before controllers and services consume them.

1 decorators

Decorator Group

Cache Models And Runtime Control

Configuration, model, injector, and method decorators from @xtaskjs/cache used to register cache models, inject repositories or services, and control read/write cache behavior in DI-managed services.

9 decorators

Decorator Group

HTTP And Browser Cache Policies

HTTP response decorators from @xtaskjs/cache used to apply Cache-Control directives, validators, and Vary behavior to routes, plus injector access to HttpCacheService.

7 decorators

Decorator Group

Scheduler Jobs And Lifecycle

Scheduling decorators from @xtaskjs/scheduler used to declare cron, interval, and timeout jobs and to inject runtime scheduler services.

5 decorators

Decorator Group

Throttling And Rate Limits

Rate-limiting decorators from @xtaskjs/throttler used to protect routes and inject runtime throttling services.

3 decorators

Decorator Group

Socket.IO Realtime Gateways

Gateway, event, and injector decorators exported by @xtaskjs/socket-io. These keep realtime handlers inside regular xtaskjs services and wire Socket.IO namespaces into the DI container.

8 decorators

Decorator Group

Queues And Messaging

Queue consumer, publish, and injector decorators exported by @xtaskjs/queues. These wire broker transports and in-memory queues into DI-managed services.

7 decorators

Decorator Group

HTTP Routing And Pipelines

Route declaration and request-pipeline decorators exported by @xtaskjs/common. These are the core HTTP building blocks used by controllers in every sample.

@xtaskjs/common Class decorator class

Controller

Defines the base route path for an HTTP controller and can attach shared middlewares, guards, and pipes.

Route prefix on a controller
import { Controller, Get } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Get("/")
  list() {
    return [];
  }
}
@xtaskjs/common Method decorator method

Get

Registers a GET route handler and optionally adds route-specific middleware, guards, or pipes.

GET route
import { Controller, Get } from "@xtaskjs/common";

@Controller("/health")
export class HealthController {
  @Get("/")
  status() {
    return { ok: true };
  }
}
@xtaskjs/common Method decorator method

Post

Registers a POST route handler for commands, form submissions, or resource creation.

POST route
import { Controller, Post } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Post("/")
  create(req: any) {
    return { email: req.body.email, created: true };
  }
}
@xtaskjs/common Method decorator method

Patch

Registers a PATCH route handler for partial updates.

PATCH route
import { Controller, Patch } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Patch("/:id")
  update(req: any) {
    return { id: req.params.id, updated: true };
  }
}
@xtaskjs/common Method decorator method

Delete

Registers a DELETE route handler for removals and destructive operations.

DELETE route
import { Controller, Delete } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Delete("/:id")
  remove(req: any) {
    return { id: req.params.id, removed: true };
  }
}
@xtaskjs/common Parameter decorator method parameter

Body

Binds request body data to a controller parameter and supports DTO transformation when validation pipes are enabled.

Read body payload
import { Body, Controller, Post } from "@xtaskjs/common";

class CreateUserDto {
  email!: string;
}

@Controller("/users")
export class UsersController {
  @Post("/")
  create(@Body() body: CreateUserDto) {
    return body;
  }
}
@xtaskjs/common Parameter decorator method parameter

Param

Extracts route parameters by name or as a full params object for typed handler input.

Read route params
import { Controller, Get, Param } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Get("/:id")
  detail(@Param("id") id: string) {
    return { id };
  }
}
@xtaskjs/common Parameter decorator method parameter

Query

Maps query-string values to a method parameter, optionally by property name.

Read query-string filters
import { Controller, Get, Query } from "@xtaskjs/common";

@Controller("/users")
export class UsersController {
  @Get("/")
  list(@Query("role") role?: string) {
    return { role };
  }
}
@xtaskjs/common Parameter decorator method parameter

Req

Injects the adapter request object into a controller handler parameter.

Access request object
import { Controller, Get, Req } from "@xtaskjs/common";

@Controller("/auth")
export class AuthController {
  @Get("/me")
  me(@Req() req: any) {
    return { auth: req.auth };
  }
}
@xtaskjs/common Parameter decorator method parameter

Res

Injects the adapter response object into a controller handler parameter.

Access response object
import { Controller, Get, Res } from "@xtaskjs/common";

@Controller("/health")
export class HealthController {
  @Get("/")
  status(@Res() res: any) {
    return { statusCode: res.statusCode || 200 };
  }
}
@xtaskjs/common Class and method decorator class or method

UseMiddlewares

Adds one or more middlewares to a controller or route so cross-cutting logic runs before the handler.

Class-level middleware
import { Controller, Get, UseMiddlewares } from "@xtaskjs/common";

const requestLogger = async (_context: any, next: () => Promise<void>) => {
  await next();
};

@Controller("/audit")
@UseMiddlewares(requestLogger)
export class AuditController {
  @Get("/")
  list() {
    return { ok: true };
  }
}
@xtaskjs/common Class and method decorator class or method

UseGuards

Attaches guard functions to a controller or route to allow, deny, or enrich request context before execution.

Route-level guard
import { Controller, Get, UseGuards } from "@xtaskjs/common";

const adminGuard = (context: any) => context.request?.headers?.["x-role"] === "admin";

@Controller("/admin")
export class AdminController {
  @Get("/")
  @UseGuards(adminGuard)
  dashboard() {
    return { secure: true };
  }
}
@xtaskjs/common Class and method decorator class or method

UsePipes

Applies argument transformation or validation functions before a route handler consumes input.

Pipe-based payload cleanup
import { Controller, Post, UsePipes } from "@xtaskjs/common";

const trimEmailPipe = (value: any) => ({ ...value, email: String(value.email || "").trim() });

@Controller("/accounts")
export class AccountController {
  @Post("/")
  @UsePipes(trimEmailPipe)
  create(req: any) {
    return req.body;
  }
}

Decorator Group

Lifecycle Runners And Events

Lifecycle decorators from @xtaskjs/common used to run startup logic, CLI tasks, and event handlers inside the application lifecycle.

@xtaskjs/common Method decorator method

OnEvent

Registers a lifecycle event handler for a given phase and execution priority.

Lifecycle phase listener
import { OnEvent } from "@xtaskjs/common";

export class AuditListener {
  @OnEvent("AFTER_CONTROLLER_HANDLER", 10)
  afterHandler() {
    console.log("controller completed");
  }
}
@xtaskjs/common Method decorator method

ApplicationRunner

Runs a method during application startup with optional priority ordering.

Startup seed
import { ApplicationRunner } from "@xtaskjs/common";
import { Service } from "@xtaskjs/core";

@Service()
export class SeedRunner {
  @ApplicationRunner(100)
  async seed() {
    console.log("seeding application data");
  }
}
@xtaskjs/common Method decorator method

CommandLineRunner

Marks a method as a command-line lifecycle runner so it can execute in CLI-oriented flows.

CLI task
import { CommandLineRunner } from "@xtaskjs/common";
import { Service } from "@xtaskjs/core";

@Service()
export class ReportsRunner {
  @CommandLineRunner(0)
  async generate() {
    console.log("generating reports");
  }
}

Decorator Group

Core DI And Components

Dependency-injection and component decorators from @xtaskjs/core. These mark providers for container discovery and select named bindings for injection.

@xtaskjs/core Class decorator class

Component

Low-level component decorator that stores DI metadata such as scope, condition, name, and primary selection.

Custom component metadata
import { Component } from "@xtaskjs/core";

@Component({ scope: "singleton", name: "clock" })
export class ClockService {}
@xtaskjs/core Class decorator class

Service

Convenience stereotype for registering a class as a DI-managed service component.

Service stereotype
import { Service } from "@xtaskjs/core";

@Service()
export class BillingService {}
@xtaskjs/core Class decorator class

Controller

Registers a class as a controller component in the DI container. This is separate from the HTTP route decorator exported by @xtaskjs/common.

DI controller stereotype
import { Controller } from "@xtaskjs/core";

@Controller({ name: "admin-controller" })
export class AdminComponent {}
@xtaskjs/core Class decorator class

Repository

Convenience stereotype for repository-like providers managed by the DI container.

Repository stereotype
import { Repository } from "@xtaskjs/core";

@Repository()
export class UserLookupRepository {}
@xtaskjs/core Property decorator property

AutoWired / Autowired

Injects a dependency into a property. The package also exports Autowired as an alias of AutoWired.

Property injection
import { AutoWired } from "@xtaskjs/core";
import { UserService } from "./user.service";

export class AccountController {
  @AutoWired({ qualifier: UserService.name })
  private readonly users!: UserService;
}
@xtaskjs/core Parameter decorator constructor parameter

Qualifier

Selects a named binding for constructor-parameter injection when multiple implementations share the same type.

Named constructor injection
import { Qualifier, Service } from "@xtaskjs/core";

@Service()
export class NotificationService {
  constructor(@Qualifier("mailer:notifications") private readonly transport: any) {}
}
@xtaskjs/core Method decorator method

PostConstruct

Marks a method to run after dependency injection completes for the instance.

Run setup after injection
import { PostConstruct, Service } from "@xtaskjs/core";

@Service()
export class BootstrapService {
  @PostConstruct()
  init() {
    console.log("initialized");
  }
}
@xtaskjs/core Method decorator method

PreDestroy

Marks a method to run when the container destroys managed instances during shutdown.

Release resources on shutdown
import { PreDestroy, Service } from "@xtaskjs/core";

@Service()
export class WorkerService {
  @PreDestroy()
  stop() {
    console.log("stopping");
  }
}

Decorator Group

Security And Authorization

Authentication, authorization, strategy, and injector decorators exported by @xtaskjs/security. These layer on top of @xtaskjs/common route metadata.

@xtaskjs/security Class and method decorator class or method

Authenticated

Requires a successful authentication result before a controller or route executes. It can target a specific strategy or strategy list.

Protect a controller
import { Controller, Get } from "@xtaskjs/common";
import { Authenticated } from "@xtaskjs/security";

@Controller("/me")
@Authenticated()
export class ProfileController {
  @Get("/")
  profile(req: any) {
    return req.user;
  }
}
@xtaskjs/security Class and method decorator class or method

Auth

Alias of Authenticated for projects that prefer a shorter decorator name.

Alias for Authenticated
import { Auth } from "@xtaskjs/security";

@Auth(["default", "encrypted"])
export class SecureAreaController {}
@xtaskjs/security Class and method decorator class or method

Roles

Applies role-based authorization requirements to an already authenticated route.

Role-gated endpoint
import { Controller, Get } from "@xtaskjs/common";
import { Authenticated, Roles } from "@xtaskjs/security";

@Controller("/admin")
@Authenticated()
export class AdminController {
  @Get("/")
  @Roles("admin")
  dashboard() {
    return { secure: true };
  }
}
@xtaskjs/security Class and method decorator class or method

AllowAnonymous

Marks a route as publicly accessible even when the surrounding controller is authenticated by default.

Public health check
import { Controller, Get } from "@xtaskjs/common";
import { AllowAnonymous, Authenticated } from "@xtaskjs/security";

@Controller("/admin")
@Authenticated()
export class AdminController {
  @Get("/health")
  @AllowAnonymous()
  health() {
    return { ok: true };
  }
}
@xtaskjs/security Class decorator class

JwtSecurityStrategy

Decorator form of registerJwtStrategy() for registering a JWT strategy definition during module loading.

Decorator-based JWT strategy
import { JwtSecurityStrategy } from "@xtaskjs/security";

@JwtSecurityStrategy({
  name: "default",
  default: true,
  secretOrKey: process.env.JWT_SECRET,
})
export class DefaultJwtStrategy {}
@xtaskjs/security Class decorator class

JweSecurityStrategy

Decorator form of registerJweStrategy() for encrypted token flows.

Decorator-based JWE strategy
import { JweSecurityStrategy } from "@xtaskjs/security";

@JweSecurityStrategy({
  name: "encrypted",
  decryptionKey: process.env.JWE_SECRET || "secret",
})
export class EncryptedStrategy {}
@xtaskjs/security Parameter and property decorator constructor parameter or property

InjectAuthenticationService

Injects the SecurityAuthenticationService registered by the security lifecycle manager.

Inject auth service
import { Service } from "@xtaskjs/core";
import { InjectAuthenticationService, SecurityAuthenticationService } from "@xtaskjs/security";

@Service()
export class SessionAuditService {
  constructor(
    @InjectAuthenticationService()
    private readonly authentication: SecurityAuthenticationService
  ) {}
}
@xtaskjs/security Parameter and property decorator constructor parameter or property

InjectAuthorizationService

Injects the SecurityAuthorizationService used for role and permission decisions.

Inject authorization service
import { Service } from "@xtaskjs/core";
import { InjectAuthorizationService, SecurityAuthorizationService } from "@xtaskjs/security";

@Service()
export class PolicyService {
  constructor(
    @InjectAuthorizationService()
    private readonly authorization: SecurityAuthorizationService
  ) {}
}
@xtaskjs/security Parameter and property decorator constructor parameter or property

InjectPassport

Injects the configured Passport instance managed by xtaskjs security.

Inject Passport
import { Service } from "@xtaskjs/core";
import { InjectPassport } from "@xtaskjs/security";

@Service()
export class PassportInspector {
  constructor(@InjectPassport() private readonly passport: any) {}
}
@xtaskjs/security Parameter and property decorator constructor parameter or property

InjectSecurityLifecycleManager

Injects the SecurityLifecycleManager so advanced services can inspect strategies or authentication state wiring.

Inject lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectSecurityLifecycleManager } from "@xtaskjs/security";

@Service()
export class SecurityDiagnosticsService {
  constructor(@InjectSecurityLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Persistence And Repositories

TypeORM registration and injection decorators exported by @xtaskjs/typeorm. These bind datasources and repositories into the same DI container.

@xtaskjs/typeorm Class decorator class

TypeOrmDataSource

Registers a TypeORM datasource definition for xtask startup and shutdown management.

Register a datasource
import { TypeOrmDataSource } from "@xtaskjs/typeorm";
import { UserEntity } from "./user.entity";

@TypeOrmDataSource({
  name: "default",
  type: "sqlite",
  database: "app.sqlite",
  entities: [UserEntity],
  synchronize: true,
})
export class DatabaseConfig {}
@xtaskjs/typeorm Parameter and property decorator constructor parameter or property

InjectDataSource

Injects a named datasource instance managed by xtaskjs TypeORM integration.

Inject the default datasource
import { Service } from "@xtaskjs/core";
import { DataSource, InjectDataSource } from "@xtaskjs/typeorm";

@Service()
export class HealthQueryService {
  constructor(@InjectDataSource() private readonly dataSource: DataSource) {}
}
@xtaskjs/typeorm Parameter and property decorator constructor parameter or property

InjectRepository

Injects a TypeORM repository for a given entity and datasource name.

Inject entity repository
import { Service } from "@xtaskjs/core";
import { InjectRepository, Repository } from "@xtaskjs/typeorm";
import { UserEntity } from "./user.entity";

@Service()
export class UsersService {
  constructor(
    @InjectRepository(UserEntity)
    private readonly users: Repository<UserEntity>
  ) {}
}
@xtaskjs/typeorm Class decorator class

TypeOrmMigration

Registers a migration class in the TypeORM migration registry for a named datasource.

Register a migration
import { MigrationInterface, QueryRunner, TypeOrmMigration } from "@xtaskjs/typeorm";

@TypeOrmMigration({ dataSourceName: "default" })
export class CreateAuditEntries1700000000000 implements MigrationInterface {
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query("CREATE TABLE audit_entries (id integer primary key autoincrement, message varchar(120) not null)");
  }

  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query("DROP TABLE audit_entries");
  }
}
@xtaskjs/typeorm Class decorator class

TypeOrmSeeder

Registers an ordered seeder class that runs after datasource initialization when seeders are enabled.

Register a startup seeder
import { DataSource, TypeOrmSeeder } from "@xtaskjs/typeorm";

@TypeOrmSeeder({ dataSourceName: "default", order: 1 })
export class AuditEntriesSeeder {
  async run(dataSource: DataSource): Promise<void> {
    await dataSource.query("INSERT INTO audit_entries (message) VALUES ('seeded')");
  }
}

Decorator Group

CQRS Buses, Handlers, And Projections

CQRS configuration, handler, projection, idempotency, and injector decorators exported by @xtaskjs/cqrs. These connect command, query, and event flows to the xtaskjs container and read or write datasource aliases.

@xtaskjs/cqrs Class decorator class

Cqrs

Decorator form of configureCqrs() for binding the read and write datasource aliases and optional idempotency store during module loading.

Bind read and write datasource aliases
import { Cqrs } from "@xtaskjs/cqrs";

@Cqrs({ writeDataSourceName: "write-db", readDataSourceName: "read-db" })
export class CqrsConfiguration {}
@xtaskjs/cqrs Class decorator class

CommandHandler

Registers a DI-managed class as the single handler for a command message type.

Command handler
import { Service } from "@xtaskjs/core";
import { CommandHandler, ICommandHandler } from "@xtaskjs/cqrs";

class CreateUserCommand {
  constructor(public readonly name: string) {}
}

@Service()
@CommandHandler(CreateUserCommand)
export class CreateUserHandler implements ICommandHandler<CreateUserCommand, string> {
  execute(command: CreateUserCommand) {
    return command.name;
  }
}
@xtaskjs/cqrs Class decorator class

QueryHandler

Registers a DI-managed class as the handler for a query message type.

Query handler
import { Service } from "@xtaskjs/core";
import { IQueryHandler, QueryHandler } from "@xtaskjs/cqrs";

class ListUsersQuery {}

@Service()
@QueryHandler(ListUsersQuery)
export class ListUsersHandler implements IQueryHandler<ListUsersQuery, string[]> {
  execute() {
    return ["Ada"];
  }
}
@xtaskjs/cqrs Class decorator class

EventHandler

Registers one or more event handlers that react after a message publishes an event on the CQRS event bus.

Event handler
import { Service } from "@xtaskjs/core";
import { EventHandler, IEventHandler } from "@xtaskjs/cqrs";

class UserCreatedEvent {
  constructor(public readonly id: string) {}
}

@Service()
@EventHandler(UserCreatedEvent)
export class UserProjectionHandler implements IEventHandler<UserCreatedEvent> {
  async handle(event: UserCreatedEvent) {
    console.log(event.id);
  }
}
@xtaskjs/cqrs Class decorator class

ProcessManager / Saga

Registers an orchestration component that reacts to events with access to command, query, and event buses. Saga is an alias of ProcessManager.

Event-driven orchestration
import { Service } from "@xtaskjs/core";
import { IProcessManager, ProcessManager, ProcessManagerContext } from "@xtaskjs/cqrs";

class UserCreatedEvent {
  constructor(public readonly id: string) {}
}

@Service()
@ProcessManager(UserCreatedEvent)
export class WelcomeProcessManager implements IProcessManager<UserCreatedEvent> {
  async handle(event: UserCreatedEvent, context: ProcessManagerContext) {
    await context.commandBus.execute({ userId: event.id });
  }
}
@xtaskjs/cqrs Class decorator class

ProjectionRebuilder

Registers a named projection rebuilder so operators or diagnostics flows can rebuild a read model from write-side state.

Named projection rebuilder
import { Service } from "@xtaskjs/core";
import { IProjectionRebuilder, ProjectionRebuilder } from "@xtaskjs/cqrs";

@Service()
@ProjectionRebuilder("users")
export class UserProjectionRebuilder implements IProjectionRebuilder {
  async rebuild() {
    console.log("rebuild read model");
  }
}
@xtaskjs/cqrs Class decorator class

IdempotentCommand

Adds idempotency metadata to a command handler so repeated executions can reuse a cached result instead of running the write-side action again.

Idempotent command handler
import { CommandHandler, IdempotentCommand } from "@xtaskjs/cqrs";

class CreateUserCommand {
  constructor(public readonly name: string, public readonly idempotencyKey: string) {}
}

@IdempotentCommand<CreateUserCommand>({ key: (command) => command.idempotencyKey })
@CommandHandler(CreateUserCommand)
export class CreateUserHandler {
  execute(command: CreateUserCommand) {
    return `${command.name}:${command.idempotencyKey}`;
  }
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectCommandBus

Injects CommandBus so controllers or services can dispatch commands without reaching into the lifecycle manager directly.

Inject command bus
import { Service } from "@xtaskjs/core";
import { CommandBus, InjectCommandBus } from "@xtaskjs/cqrs";

@Service()
export class UsersFacade {
  constructor(@InjectCommandBus() private readonly commandBus: CommandBus) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectQueryBus

Injects QueryBus so read-side requests can be dispatched from controllers, presenters, or services.

Inject query bus
import { Service } from "@xtaskjs/core";
import { InjectQueryBus, QueryBus } from "@xtaskjs/cqrs";

@Service()
export class ReportsFacade {
  constructor(@InjectQueryBus() private readonly queryBus: QueryBus) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectEventBus

Injects EventBus so handlers can publish follow-up domain or integration events after write-side work completes.

Inject event bus
import { Service } from "@xtaskjs/core";
import { EventBus, InjectEventBus } from "@xtaskjs/cqrs";

@Service()
export class UserEventsPublisher {
  constructor(@InjectEventBus() private readonly events: EventBus) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectIdempotencyStore

Injects the configured idempotency store implementation used by idempotent command handlers.

Inject idempotency store
import { InjectIdempotencyStore, IIdempotencyStore } from "@xtaskjs/cqrs";
import { Service } from "@xtaskjs/core";

@Service()
export class IdempotencyDiagnosticsService {
  constructor(@InjectIdempotencyStore() private readonly store: IIdempotencyStore) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectReadDataSource

Injects the configured read-side datasource alias managed by CQRS and backed by @xtaskjs/typeorm.

Inject read datasource
import { Service } from "@xtaskjs/core";
import { InjectReadDataSource } from "@xtaskjs/cqrs";
import { DataSource } from "@xtaskjs/typeorm";

@Service()
export class ReadDiagnosticsService {
  constructor(@InjectReadDataSource() private readonly readDataSource: DataSource) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectWriteDataSource

Injects the configured write-side datasource alias for command handlers or projection rebuilders that need direct datasource access.

Inject write datasource
import { Service } from "@xtaskjs/core";
import { InjectWriteDataSource } from "@xtaskjs/cqrs";
import { DataSource } from "@xtaskjs/typeorm";

@Service()
export class WriteDiagnosticsService {
  constructor(@InjectWriteDataSource() private readonly writeDataSource: DataSource) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectReadRepository

Injects a repository from the configured read-side datasource alias so queries can stay projection-focused.

Inject read repository
import { Service } from "@xtaskjs/core";
import { InjectReadRepository } from "@xtaskjs/cqrs";
import { Repository } from "@xtaskjs/typeorm";

class UserProjection {}

@Service()
export class UsersReadService {
  constructor(@InjectReadRepository(UserProjection) private readonly users: Repository<UserProjection>) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectWriteRepository

Injects a repository from the configured write-side datasource alias for command handlers and write-model maintenance flows.

Inject write repository
import { Service } from "@xtaskjs/core";
import { InjectWriteRepository } from "@xtaskjs/cqrs";
import { Repository } from "@xtaskjs/typeorm";

class UserEntity {}

@Service()
export class UsersWriteService {
  constructor(@InjectWriteRepository(UserEntity) private readonly users: Repository<UserEntity>) {}
}
@xtaskjs/cqrs Parameter and property decorator constructor parameter or property

InjectCqrsLifecycleManager

Injects the CqrsLifecycleManager for advanced diagnostics, projection rebuild operations, and direct runtime inspection.

Inject CQRS lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectCqrsLifecycleManager } from "@xtaskjs/cqrs";

@Service()
export class CqrsDiagnosticsService {
  constructor(@InjectCqrsLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Event Sourcing And Stored Events

Configuration, aggregate, subscriber, and injector decorators exported by @xtaskjs/event-source. These wire aggregate metadata, event appliers, repositories, and stored-event subscribers into the xtaskjs lifecycle.

@xtaskjs/event-source Class decorator class

EventSource

Decorator form of configureEventSource() for registering the event store, publisher, and optional runtime flags during module loading.

Configure durable event storage
import { EventSource, createTypeOrmEventStore } from "@xtaskjs/event-source";

@EventSource({
  store: createTypeOrmEventStore({ dataSourceName: "write-db", tableName: "event_store" }),
})
export class EventSourceConfiguration {}
@xtaskjs/event-source Class decorator class

EventSourcedAggregate

Registers aggregate metadata such as the aggregate name and stream key so repositories can load and persist event streams consistently.

Declare an aggregate stream
import { EventSourcedAggregate, EventSourcedAggregateRoot } from "@xtaskjs/event-source";

@EventSourcedAggregate({ stream: "users" })
export class UserAggregate extends EventSourcedAggregateRoot {}
@xtaskjs/event-source Method decorator method

ApplyEvent

Registers the method that mutates aggregate state for a given event type during both live execution and historical replay.

Apply an aggregate event
import { ApplyEvent } from "@xtaskjs/event-source";

class UserRegisteredEvent {
  constructor(public readonly email: string) {}
}

export class UserAggregate {
  public email?: string;

  @ApplyEvent(UserRegisteredEvent)
  onRegistered(event: UserRegisteredEvent) {
    this.email = event.email;
  }
}
@xtaskjs/event-source Class decorator class

EventSourceSubscriber / StoredEventSubscriber

Registers a DI-managed subscriber that reacts after stored events are appended, making it suitable for projections, integrations, and side effects.

React to stored events
import { Service } from "@xtaskjs/core";
import { EventSourceSubscriber, IEventSourceSubscriber } from "@xtaskjs/event-source";

class UserRegisteredEvent {
  constructor(public readonly email: string) {}
}

@Service()
@EventSourceSubscriber(UserRegisteredEvent)
export class WelcomeProjection implements IEventSourceSubscriber<UserRegisteredEvent> {
  handle(event: UserRegisteredEvent) {
    console.log(event.email);
  }
}
@xtaskjs/event-source Parameter and property decorator constructor parameter or property

InjectEventSourceRepository

Injects the repository for a specific event-sourced aggregate so services can create, load, and save streams through the lifecycle-managed store.

Inject an aggregate repository
import { Service } from "@xtaskjs/core";
import { EventSourceRepository, InjectEventSourceRepository } from "@xtaskjs/event-source";

class UserAggregate {}

@Service()
export class UserService {
  constructor(
    @InjectEventSourceRepository(UserAggregate)
    private readonly users: EventSourceRepository<any>
  ) {}
}
@xtaskjs/event-source Parameter and property decorator constructor parameter or property

InjectEventStore

Injects the active event store implementation when advanced services need direct stream append or load access.

Inject the event store
import { Service } from "@xtaskjs/core";
import { InjectEventStore } from "@xtaskjs/event-source";

@Service()
export class EventStoreDiagnosticsService {
  constructor(@InjectEventStore() private readonly store: any) {}
}
@xtaskjs/event-source Parameter and property decorator constructor parameter or property

InjectEventSourceBus

Injects the in-process stored-event bus so services can publish persisted envelopes to local subscribers when they need low-level runtime control.

Inject the stored-event bus
import { Service } from "@xtaskjs/core";
import { InjectEventSourceBus } from "@xtaskjs/event-source";

@Service()
export class EventReplayService {
  constructor(@InjectEventSourceBus() private readonly bus: any) {}
}
@xtaskjs/event-source Parameter and property decorator constructor parameter or property

InjectEventPublisher

Injects the configured external event publisher so services can inspect or extend publication behavior beyond the default queue bridge.

Inject the external publisher
import { Service } from "@xtaskjs/core";
import { InjectEventPublisher } from "@xtaskjs/event-source";

@Service()
export class EventPublisherDiagnosticsService {
  constructor(@InjectEventPublisher() private readonly publisher: any) {}
}
@xtaskjs/event-source Parameter and property decorator constructor parameter or property

InjectEventSourceLifecycleManager

Injects the EventSourceLifecycleManager for repository lookup, initialization checks, subscriber inspection, and lower-level event-source runtime access.

Inject the event-source lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectEventSourceLifecycleManager } from "@xtaskjs/event-source";

@Service()
export class EventSourceDiagnosticsService {
  constructor(@InjectEventSourceLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Mailer Templates And Delivery

Mailer decorators exported by @xtaskjs/mailer. These register transports and templates and inject delivery services into DI-managed classes.

@xtaskjs/mailer Class decorator class

MailerTransport

Decorator form of registerMailerTransport() for registering a named mail transport during module loading.

Register a transport with a decorator
import { MailerTransport, createMailtrapTransportOptions } from "@xtaskjs/mailer";

const transport = process.env.MAIL_TRANSPORT_PROVIDER === "smtp"
  ? {
      host: process.env.MAIL_SMTP_HOST || "smtp.example.com",
      port: Number(process.env.MAIL_SMTP_PORT || 587),
      secure: process.env.MAIL_SMTP_SECURE === "true",
      auth: {
        user: process.env.MAIL_SMTP_USER || "user",
        pass: process.env.MAIL_SMTP_PASS || "pass",
      },
    }
  : createMailtrapTransportOptions({
      username: process.env.MAILTRAP_SMTP_USER || "user",
      password: process.env.MAILTRAP_SMTP_PASS || "pass",
      host: process.env.MAILTRAP_SMTP_HOST || "sandbox.smtp.mailtrap.io",
      port: Number(process.env.MAILTRAP_SMTP_PORT || 2525),
      secure: process.env.MAILTRAP_SMTP_SECURE === "true",
    });

@MailerTransport({
  name: "default",
  defaults: { from: "hello@xtaskjs.dev" },
  transport,
})
export class DefaultTransportRegistration {}
@xtaskjs/mailer Class decorator class

MailerTemplate

Decorator form of registerMailerTemplate() for reusable inline or file-rendered email templates.

Register a template
import { MailerTemplate } from "@xtaskjs/mailer";

@MailerTemplate({
  name: "welcome",
  subject: "Welcome {{user.name}}",
  text: "Hello {{user.name}}",
  html: "<h1>Hello {{user.name}}</h1>",
})
export class WelcomeTemplateRegistration {}
@xtaskjs/mailer Parameter and property decorator constructor parameter or property

InjectMailerService

Injects MailerService so a DI-managed service can render templates and send mail.

Inject mailer service
import { Service } from "@xtaskjs/core";
import { InjectMailerService, MailerService } from "@xtaskjs/mailer";

@Service()
export class EmailService {
  constructor(@InjectMailerService() private readonly mailer: MailerService) {}
}
@xtaskjs/mailer Parameter and property decorator constructor parameter or property

InjectMailerTransport

Injects a named transport so a service can send directly on a specific channel such as notifications.

Inject notifications transport
import { Service } from "@xtaskjs/core";
import { InjectMailerTransport, MailerTransporter } from "@xtaskjs/mailer";

@Service()
export class AlertsService {
  constructor(
    @InjectMailerTransport("notifications")
    private readonly notifications: MailerTransporter
  ) {}
}
@xtaskjs/mailer Parameter and property decorator constructor parameter or property

InjectMailerLifecycleManager

Injects the MailerLifecycleManager for advanced inspection, verification, or transporter lookup.

Inject lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectMailerLifecycleManager } from "@xtaskjs/mailer";

@Service()
export class MailDiagnosticsService {
  constructor(@InjectMailerLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Internationalization And Locale Resolution

Configuration and injector decorators exported by @xtaskjs/internationalization. These register locale behavior and expose translation services inside DI-managed classes.

@xtaskjs/internationalization Class decorator class

Internationalization

Decorator form of configureInternationalization() for registering default locale, fallback locale, currency, and timezone settings during module loading.

Register base internationalization settings
import { Internationalization } from "@xtaskjs/internationalization";

@Internationalization({
  defaultLocale: "en-US",
  fallbackLocale: "en-US",
  defaultCurrency: "USD",
  defaultTimeZone: "UTC",
})
export class AppI18nConfiguration {}
@xtaskjs/internationalization Class decorator class

InternationalizationLocale

Registers a locale definition with translations, locale-specific currency and timezone values, and optional namespace dictionaries.

Register a locale catalog
import { InternationalizationLocale } from "@xtaskjs/internationalization";

@InternationalizationLocale({
  locale: "es-ES",
  currency: "EUR",
  timeZone: "Europe/Madrid",
  translations: { home: { title: "Bienvenida" } },
})
export class SpanishLocaleRegistration {}
@xtaskjs/internationalization Class decorator class

InternationalizationResolver

Registers a custom locale resolver that can derive locale context from the request, headers, container state, or tenant metadata.

Custom locale resolver
import { InternationalizationResolver } from "@xtaskjs/internationalization";

@InternationalizationResolver(({ request }) => {
  return request?.headers?.["x-locale"] || request?.query?.locale;
})
export class HeaderLocaleResolver {}
@xtaskjs/internationalization Parameter and property decorator constructor parameter or property

InjectInternationalizationService

Injects InternationalizationService so controllers and services can translate keys, format values, inspect locales, and load namespaces on demand.

Inject translation service
import { Service } from "@xtaskjs/core";
import { InjectInternationalizationService, InternationalizationService } from "@xtaskjs/internationalization";

@Service()
export class CheckoutPresenter {
  constructor(
    @InjectInternationalizationService()
    private readonly intl: InternationalizationService
  ) {}
}
@xtaskjs/internationalization Parameter and property decorator constructor parameter or property

InjectI18nService

Alias of InjectInternationalizationService for shorter injection syntax in services and controllers.

Inject i18n service alias
import { InjectI18nService, InternationalizationService } from "@xtaskjs/internationalization";
import { Service } from "@xtaskjs/core";

@Service()
export class AliasI18nService {
  constructor(@InjectI18nService() private readonly intl: InternationalizationService) {}
}
@xtaskjs/internationalization Parameter and property decorator constructor parameter or property

InjectInternationalizationLifecycleManager

Injects the InternationalizationLifecycleManager for advanced inspection of loaded locales, namespaces, request context, or formatter registration.

Inject internationalization lifecycle
import { Service } from "@xtaskjs/core";
import { InjectInternationalizationLifecycleManager } from "@xtaskjs/internationalization";

@Service()
export class LocaleDiagnosticsService {
  constructor(
    @InjectInternationalizationLifecycleManager()
    private readonly lifecycle: any
  ) {}
}
@xtaskjs/internationalization Parameter and property decorator constructor parameter or property

InjectI18nLifecycleManager

Alias of InjectInternationalizationLifecycleManager for compact naming in diagnostics and infrastructure services.

Inject i18n lifecycle alias
import { InjectI18nLifecycleManager } from "@xtaskjs/internationalization";
import { Service } from "@xtaskjs/core";

@Service()
export class AliasLifecycleService {
  constructor(@InjectI18nLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Value Objects And DTO Transformation

DTO-oriented decorators from @xtaskjs/value-objects that turn raw request fields into normalized domain wrappers before controllers and services consume them.

@xtaskjs/value-objects Property decorator class property

TransformValueObject

Transforms raw DTO input into a value object instance during class-transformer conversion so downstream code receives a validated wrapper instead of a primitive.

Normalize DTO email input
import { plainToInstance } from "class-transformer";
import { StringValueObject, TransformValueObject } from "@xtaskjs/value-objects";

class EmailAddress extends StringValueObject {
  constructor(value: string) {
    super(value.trim().toLowerCase());
  }
}

class CreateUserDto {
  @TransformValueObject(EmailAddress)
  email!: EmailAddress;
}

const dto = plainToInstance(CreateUserDto, { email: " USER@Example.com " });

Decorator Group

Cache Models And Runtime Control

Configuration, model, injector, and method decorators from @xtaskjs/cache used to register cache models, inject repositories or services, and control read/write cache behavior in DI-managed services.

@xtaskjs/cache Class decorator class

CacheSettings

Decorator form of configureCache() for setting package-wide defaults such as driver, TTL, namespace, Redis options, and HTTP cache defaults while modules load.

Decorator-based cache defaults
import { CacheSettings } from "@xtaskjs/cache";

@CacheSettings({
  defaultDriver: "memory",
  defaultTtl: "30s",
  namespace: "catalog",
})
export class CacheConfiguration {}
@xtaskjs/cache Class decorator class

CacheModel

Registers a named cache model with driver selection, TTL defaults, serialization hooks, and optional Redis-specific overrides.

Register a cache model
import { CacheModel } from "@xtaskjs/cache";

@CacheModel({ name: "products", ttl: "5m", driver: "redis" })
export class ProductCacheModel {}
@xtaskjs/cache Parameter and property decorator constructor parameter or property

InjectCacheService

Injects CacheService for model-level operations such as listModels(), get(), set(), remember(), delete(), and clear().

Inject the cache service
import { Service } from "@xtaskjs/core";
import { CacheService, InjectCacheService } from "@xtaskjs/cache";

@Service()
export class CacheInspectorService {
  constructor(
    @InjectCacheService()
    private readonly cache: CacheService
  ) {}
}
@xtaskjs/cache Parameter and property decorator constructor parameter or property

InjectCacheRepository

Injects a model-scoped CacheRepository<T> so services can work directly with entries, hit metadata, and per-model TTL behavior.

Inject a cache repository
import { Service } from "@xtaskjs/core";
import { CacheRepository, InjectCacheRepository } from "@xtaskjs/cache";
import { ProductCacheModel } from "./product-cache.model";

@Service()
export class ProductCacheReader {
  constructor(
    @InjectCacheRepository(ProductCacheModel)
    private readonly products: CacheRepository<any>
  ) {}
}
@xtaskjs/cache Parameter and property decorator constructor parameter or property

InjectCacheLifecycleManager

Injects the lower-level cache lifecycle manager for diagnostics, initialization checks, repository resolution, and runtime state access.

Inject the cache lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectCacheLifecycleManager } from "@xtaskjs/cache";

@Service()
export class CacheLifecycleDiagnosticsService {
  constructor(
    @InjectCacheLifecycleManager()
    private readonly lifecycle: any
  ) {}
}
@xtaskjs/cache Parameter and property decorator constructor parameter or property

InjectCacheAdminService

Injects CacheAdminService for runtime inspection of models, entries, and effective HTTP cache metadata resolved from decorated routes.

Inject the cache admin service
import { Service } from "@xtaskjs/core";
import { CacheAdminService, InjectCacheAdminService } from "@xtaskjs/cache";

@Service()
export class CacheAdminInspector {
  constructor(
    @InjectCacheAdminService()
    private readonly cacheAdmin: CacheAdminService
  ) {}
}
@xtaskjs/cache Method decorator method

Cacheable

Reads through the configured repository. Cache hits skip method execution, while misses store the resolved result using an optional key builder, TTL override, and unless condition.

Read-through caching
import { Service } from "@xtaskjs/core";
import { Cacheable } from "@xtaskjs/cache";
import { ProductCacheModel } from "./product-cache.model";

@Service()
export class ProductService {
  @Cacheable({ model: ProductCacheModel, key: (id: string) => id, ttl: "15m" })
  async getProduct(id: string) {
    return { id, generatedAt: new Date().toISOString() };
  }
}
@xtaskjs/cache Method decorator method

CachePut

Always runs the method and then writes the returned value into the cache, optionally guarding the write with when and overriding the stored TTL.

Write-through cache refresh
import { Service } from "@xtaskjs/core";
import { CachePut } from "@xtaskjs/cache";
import { ProductCacheModel } from "./product-cache.model";

@Service()
export class ProductRefreshService {
  @CachePut({ model: ProductCacheModel, key: (id: string) => id })
  async refreshProduct(id: string) {
    return { id, refreshedAt: new Date().toISOString() };
  }
}
@xtaskjs/cache Method decorator method

CacheEvict

Removes one cached entry or clears an entire model before or after the wrapped method runs, with optional key resolution and conditional execution.

Evict one key or a whole model
import { Service } from "@xtaskjs/core";
import { CacheEvict } from "@xtaskjs/cache";
import { ProductCacheModel } from "./product-cache.model";

@Service()
export class ProductInvalidationService {
  @CacheEvict({ model: ProductCacheModel, key: (id: string) => id })
  async evictProduct(id: string) {
    return true;
  }
}

Decorator Group

HTTP And Browser Cache Policies

HTTP response decorators from @xtaskjs/cache used to apply Cache-Control directives, validators, and Vary behavior to routes, plus injector access to HttpCacheService.

@xtaskjs/cache Parameter and property decorator constructor parameter or property

InjectHttpCacheService

Injects HttpCacheService so services or controllers can build cache headers manually, inspect policy normalization, or describe effective route behavior.

Inject the HTTP cache service
import { Service } from "@xtaskjs/core";
import { HttpCacheService, InjectHttpCacheService } from "@xtaskjs/cache";

@Service()
export class CacheHeaderService {
  constructor(
    @InjectHttpCacheService()
    private readonly httpCache: HttpCacheService
  ) {}
}
@xtaskjs/cache Class and method decorator class or method

CacheResponse

Applies a full HTTP cache policy to responses, including visibility, max-age, stale directives, ETag, Last-Modified, Expires, Vary, and conditional application rules.

Apply a custom HTTP cache policy
import { Controller, Get } from "@xtaskjs/common";
import { CacheResponse } from "@xtaskjs/cache";

@Controller("/reports")
export class ReportsController {
  @CacheResponse({ visibility: "private", maxAge: "60s", mustRevalidate: true })
  @Get("/summary")
  summary() {
    return { ok: true };
  }
}
@xtaskjs/cache Class and method decorator class or method

BrowserCache / CacheHeaders

Alias names for CacheResponse() when the intent is browser-facing cache headers rather than a generic response policy decorator.

Alias for browser cache headers
import { Controller, Get } from "@xtaskjs/common";
import { BrowserCache } from "@xtaskjs/cache";

@Controller("/articles")
export class ArticleController {
  @BrowserCache({ maxAge: "1m", staleWhileRevalidate: "30s" })
  @Get("/:slug")
  show() {
    return { published: true };
  }
}
@xtaskjs/cache Class and method decorator class or method

CacheView

Applies the same HTTP cache policy surface as CacheResponse(), but only when the decorated route returns view(...).

Cache rendered views only
import { Controller, Get } from "@xtaskjs/common";
import { view } from "@xtaskjs/core";
import { CacheView } from "@xtaskjs/cache";

@Controller("/")
export class WebController {
  @CacheView({ maxAge: "10m", etag: true })
  @Get("/")
  home() {
    return view("home", { title: "Welcome" });
  }
}
@xtaskjs/cache Class and method decorator class or method

NoStore

Disables browser storage for sensitive responses by combining no-store, no-cache, must-revalidate, and an already-expired Expires value.

Disable browser storage
import { Controller, Get } from "@xtaskjs/common";
import { NoStore } from "@xtaskjs/cache";

@Controller("/drafts")
export class DraftController {
  @NoStore()
  @Get("/preview")
  preview() {
    return { draft: true };
  }
}
@xtaskjs/cache Class and method decorator class or method

NoCache

Forces revalidation by emitting no-cache and must-revalidate semantics while still allowing conditional requests when other validators are enabled.

Force revalidation
import { Controller, Get } from "@xtaskjs/common";
import { NoCache } from "@xtaskjs/cache";

@Controller("/profile")
export class ProfileController {
  @NoCache()
  @Get("/")
  show() {
    return { profile: true };
  }
}
@xtaskjs/cache Class and method decorator class or method

VaryBy

Appends Vary header values so downstream caches distinguish responses by headers such as Accept-Language or Authorization.

Vary by request headers
import { Controller, Get } from "@xtaskjs/common";
import { BrowserCache, VaryBy } from "@xtaskjs/cache";

@Controller("/catalog")
export class CatalogController {
  @BrowserCache({ maxAge: "2m" })
  @VaryBy("accept-language", "authorization")
  @Get("/")
  list() {
    return { ok: true };
  }
}

Decorator Group

Scheduler Jobs And Lifecycle

Scheduling decorators from @xtaskjs/scheduler used to declare cron, interval, and timeout jobs and to inject runtime scheduler services.

@xtaskjs/scheduler Method decorator method

Cron

Registers a cron-based recurring job with optional groups, retries, timezone overrides, and boot execution behavior.

Cron job
import { Service } from "@xtaskjs/core";
import { Cron } from "@xtaskjs/scheduler";

@Service()
export class ReportsScheduler {
  @Cron("0 */5 * * * *", { name: "reports.flush", group: ["reports", "nightly"] })
  flushReports() {
    console.log("flush pending reports");
  }
}
@xtaskjs/scheduler Method decorator method

Every / Interval

Registers a fixed-interval recurring job. Interval is an alias of Every for projects that prefer the more explicit name.

Interval job
import { Service } from "@xtaskjs/core";
import { Every } from "@xtaskjs/scheduler";

@Service()
export class CacheScheduler {
  @Every("10m", { name: "cache.compact", runOnInit: true })
  compact() {
    console.log("compact cache");
  }
}
@xtaskjs/scheduler Method decorator method

Timeout

Registers a one-shot delayed task that runs after startup instead of on a recurring cadence.

Delayed warmup job
import { Service } from "@xtaskjs/core";
import { Timeout } from "@xtaskjs/scheduler";

@Service()
export class WarmupScheduler {
  @Timeout("30s", { name: "cache.warmup" })
  warmup() {
    console.log("warm cache once after startup");
  }
}
@xtaskjs/scheduler Parameter and property decorator constructor parameter or property

InjectSchedulerService

Injects SchedulerService so services or controllers can inspect jobs and trigger groups or individual jobs manually.

Inject scheduler service
import { Service } from "@xtaskjs/core";
import { InjectSchedulerService, SchedulerService } from "@xtaskjs/scheduler";

@Service()
export class SchedulerInspector {
  constructor(
    @InjectSchedulerService()
    private readonly scheduler: SchedulerService
  ) {}
}
@xtaskjs/scheduler Parameter and property decorator constructor parameter or property

InjectSchedulerLifecycleManager

Injects the SchedulerLifecycleManager for lower-level control over startup state, active handles, and discovered job metadata.

Inject scheduler lifecycle
import { Service } from "@xtaskjs/core";
import { InjectSchedulerLifecycleManager } from "@xtaskjs/scheduler";

@Service()
export class SchedulerDiagnosticsService {
  constructor(
    @InjectSchedulerLifecycleManager()
    private readonly lifecycle: any
  ) {}
}

Decorator Group

Throttling And Rate Limits

Rate-limiting decorators from @xtaskjs/throttler used to protect routes and inject runtime throttling services.

@xtaskjs/throttler Class and method decorator class or method

Throttle

Applies request throttling with a limit and TTL window, integrating with guard execution for protected endpoints.

Protect endpoint with limit
import { Controller, Get } from "@xtaskjs/common";
import { Throttle } from "@xtaskjs/throttler";

@Controller("/auth")
export class AuthController {
  @Get("/login")
  @Throttle(10, "1m")
  login() {
    return { ok: true };
  }
}
@xtaskjs/throttler Parameter and property decorator constructor parameter or property

InjectThrottlerService

Injects ThrottlerService for runtime inspection and programmatic throttling operations.

Inject throttler service
import { Service } from "@xtaskjs/core";
import { InjectThrottlerService } from "@xtaskjs/throttler";

@Service()
export class ThrottlerDiagnosticsService {
  constructor(@InjectThrottlerService() private readonly throttler: any) {}
}
@xtaskjs/throttler Parameter and property decorator constructor parameter or property

InjectThrottlerLifecycleManager

Injects the throttler lifecycle manager for advanced diagnostics and low-level store integration checks.

Inject throttler lifecycle
import { Service } from "@xtaskjs/core";
import { InjectThrottlerLifecycleManager } from "@xtaskjs/throttler";

@Service()
export class ThrottlerLifecycleService {
  constructor(@InjectThrottlerLifecycleManager() private readonly lifecycle: any) {}
}

Decorator Group

Socket.IO Realtime Gateways

Gateway, event, and injector decorators exported by @xtaskjs/socket-io. These keep realtime handlers inside regular xtaskjs services and wire Socket.IO namespaces into the DI container.

@xtaskjs/socket-io Class decorator class

SocketGateway

Marks a DI-managed service as a realtime gateway, assigning namespace, optional name, groups, and disabled state for lifecycle discovery.

Decorated realtime gateway
import { Service } from "@xtaskjs/core";
import { SocketGateway } from "@xtaskjs/socket-io";

@Service()
@SocketGateway({ namespace: "/chat", group: ["realtime", "chat"] })
export class ChatGateway {}
@xtaskjs/socket-io Method decorator method

OnSocketConnection

Runs when a client connects to the gateway namespace and receives the connected socket plus handler context.

Track client connections
import { Service } from "@xtaskjs/core";
import { OnSocketConnection, SocketGateway } from "@xtaskjs/socket-io";

@Service()
@SocketGateway({ namespace: "/chat" })
export class PresenceGateway {
  @OnSocketConnection()
  onConnect(socket: any, context: { namespace: any }) {
    context.namespace.emit("presence.updated", { socketId: socket.id });
  }
}
@xtaskjs/socket-io Method decorator method

OnSocketDisconnect

Runs when Socket.IO disconnects a client, making it a good place to update presence, release room state, or log disconnect reasons.

Handle disconnect reasons
import { Service } from "@xtaskjs/core";
import { OnSocketDisconnect, SocketGateway } from "@xtaskjs/socket-io";

@Service()
@SocketGateway({ namespace: "/chat" })
export class PresenceGateway {
  @OnSocketDisconnect()
  onDisconnect(reason: string, socket: any) {
    console.log(`socket ${socket.id} disconnected: ${reason}`);
  }
}
@xtaskjs/socket-io Method decorator method

OnSocketEvent / SubscribeMessage

Registers a named Socket.IO event handler, optionally overrides namespace or handler options, and automatically acknowledges returned values when the client expects an ack.

Named chat event with acknowledgement
import { Service } from "@xtaskjs/core";
import { OnSocketEvent, SocketGateway } from "@xtaskjs/socket-io";

@Service()
@SocketGateway({ namespace: "/chat" })
export class ChatGateway {
  @OnSocketEvent("chat.message")
  onMessage(payload: { text: string }, context: { socket: any }) {
    return { ok: true, socketId: context.socket.id, text: payload.text };
  }
}
@xtaskjs/socket-io Parameter and property decorator constructor parameter or property

InjectSocketService

Injects SocketIoService so controllers and services can emit events, inspect namespaces, and list discovered gateways.

Inject the socket helper service
import { Service } from "@xtaskjs/core";
import { InjectSocketService, SocketIoService } from "@xtaskjs/socket-io";

@Service()
export class AnnouncementService {
  constructor(
    @InjectSocketService()
    private readonly sockets: SocketIoService
  ) {}
}
@xtaskjs/socket-io Parameter and property decorator constructor parameter or property

InjectSocketLifecycleManager

Injects the SocketIoLifecycleManager for lower-level diagnostics, gateway inspection, namespace access, or manual emit control.

Inject the socket lifecycle manager
import { Service } from "@xtaskjs/core";
import { InjectSocketLifecycleManager } from "@xtaskjs/socket-io";

@Service()
export class SocketDiagnosticsService {
  constructor(
    @InjectSocketLifecycleManager()
    private readonly lifecycle: any
  ) {}
}
@xtaskjs/socket-io Parameter and property decorator constructor parameter or property

InjectSocketServer

Injects the root Socket.IO server instance when low-level adapter APIs or global broadcasts are required.

Inject the root Socket.IO server
import { Service } from "@xtaskjs/core";
import { InjectSocketServer } from "@xtaskjs/socket-io";

@Service()
export class SocketServerBridge {
  constructor(
    @InjectSocketServer()
    private readonly server: any
  ) {}
}
@xtaskjs/socket-io Parameter and property decorator constructor parameter or property

InjectSocketNamespace

Injects one namespace instance by name so services can target a specific room topology without routing every emit through the root server.

Inject a named namespace
import { Service } from "@xtaskjs/core";
import { InjectSocketNamespace } from "@xtaskjs/socket-io";

@Service()
export class ChatNamespacePublisher {
  constructor(
    @InjectSocketNamespace("/chat")
    private readonly namespace: any
  ) {}
}

Decorator Group

Queues And Messaging

Queue consumer, publish, and injector decorators exported by @xtaskjs/queues. These wire broker transports and in-memory queues into DI-managed services.

@xtaskjs/queues Method decorator method

QueueHandler

Registers a named queue consumer for a concrete queue and supports retries, groups, dead-letter routing, and transport selection.

Queue-specific consumer
import { Service } from "@xtaskjs/core";
import { QueueHandler } from "@xtaskjs/queues";

@Service()
export class OrdersConsumer {
  @QueueHandler("orders.created", {
    name: "orders.created.consumer",
    transportName: "memory",
    maxRetries: 3,
    deadLetterQueue: "orders.dead",
  })
  async onOrderCreated(payload: { orderId: string }) {
    console.log("created", payload.orderId);
  }
}
@xtaskjs/queues Method decorator method

QueuePattern

Registers a topic or pattern-based listener that can subscribe to wildcards or broker topic filters depending on the transport.

Pattern listener
import { Service } from "@xtaskjs/core";
import { QueuePattern } from "@xtaskjs/queues";

@Service()
export class AuditConsumer {
  @QueuePattern("orders.*", {
    name: "orders.audit",
    transportName: "rabbitmq",
  })
  onOrderEvent(payload: any, context: { queue: string }) {
    console.log(context.queue, payload);
  }
}
@xtaskjs/queues Method decorator method

QueueSubscribe

Alias of QueueHandler for queue-specific consumers when teams prefer a subscribe-oriented naming style.

Alias of QueueHandler
import { QueueSubscribe } from "@xtaskjs/queues";
import { Service } from "@xtaskjs/core";

@Service()
export class BillingConsumer {
  @QueueSubscribe("billing.invoice.created")
  onInvoice(payload: { invoiceId: string }) {
    return payload.invoiceId;
  }
}
@xtaskjs/queues Method decorator method

PublishToQueue

Publishes the resolved method result to a queue after the method completes while preserving the original return value.

Publish method result
import { Service } from "@xtaskjs/core";
import { PublishToQueue } from "@xtaskjs/queues";

@Service()
export class CheckoutService {
  @PublishToQueue("checkout.completed", { transportName: "memory" })
  complete(orderId: string) {
    return { orderId, status: "completed" };
  }
}
@xtaskjs/queues Parameter and property decorator constructor parameter or property

InjectQueueService

Injects QueueService so services or controllers can publish messages, create producers, and inspect runtime consumers and transports.

Inject queue service
import { Service } from "@xtaskjs/core";
import { InjectQueueService, QueueService } from "@xtaskjs/queues";

@Service()
export class QueuePublisher {
  constructor(
    @InjectQueueService()
    private readonly queues: QueueService
  ) {}
}
@xtaskjs/queues Parameter and property decorator constructor parameter or property

InjectQueueLifecycleManager

Injects QueueLifecycleManager for advanced consumer, transport, and startup diagnostics.

Inject queue lifecycle manager
import { InjectQueueLifecycleManager } from "@xtaskjs/queues";
import { Service } from "@xtaskjs/core";

@Service()
export class QueueLifecycleDiagnostics {
  constructor(@InjectQueueLifecycleManager() private readonly lifecycle: any) {}
}
@xtaskjs/queues Parameter and property decorator constructor parameter or property

InjectQueueTransport

Injects a named QueueTransport implementation when low-level broker publish or subscription control is required.

Inject named queue transport
import { Service } from "@xtaskjs/core";
import { InjectQueueTransport } from "@xtaskjs/queues";

@Service()
export class QueueTransportDiagnostics {
  constructor(
    @InjectQueueTransport("rabbitmq")
    private readonly transport: any
  ) {}
}