Skip to content

Module Registration

Static configuration

Use SynkroModule.forRoot() when your configuration values are available at import time.

import { Module } from "@nestjs/common";
import { SynkroModule } from "@synkro/nestjs";
@Module({
imports: [
SynkroModule.forRoot({
transport: "redis",
connectionUrl: "redis://localhost:6379",
workflows: [
// workflow definitions (see Decorators page)
],
}),
],
})
export class AppModule {}

Async configuration

Use SynkroModule.forRootAsync() when you need to resolve configuration from ConfigService, a database, or any other async provider.

import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { SynkroModule } from "@synkro/nestjs";
@Module({
imports: [
ConfigModule.forRoot(),
SynkroModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
transport: "redis",
connectionUrl: config.getOrThrow("REDIS_URL"),
debug: config.get("SYNKRO_DEBUG") === "true",
}),
}),
],
})
export class AppModule {}

SynkroModuleOptions

PropertyTypeRequiredDescription
transport"redis" | "in-memory"YesEvent transport backend.
connectionUrlstringNoRedis connection URL. Required when transport is "redis".
debugbooleanNoEnable debug logging.
workflowsNestSynkroWorkflow[]NoWorkflow definitions. Step handlers can be inline or bound via @OnWorkflowStep.
retentionRetentionConfigNoTTL overrides for internal state keys.

Retention configuration

All values are in seconds.

SynkroModule.forRoot({
transport: "redis",
connectionUrl: "redis://localhost:6379",
retention: {
lockTtl: 30,
dedupTtl: 60,
stateTtl: 86400,
metricsTtl: 604800,
},
});
KeyDescription
lockTtlDuration a processing lock is held before it expires.
dedupTtlWindow during which duplicate event deliveries are suppressed.
stateTtlHow long workflow state is kept after completion.
metricsTtlHow long event metrics are retained.