Optionaltoken: InjectionToken<T>Optional DI token for service resolution
@Transient()
export class UserService {
constructor(@inject(DI_TOKENS.Database) private db: DatabaseService) {}
}
// In module:
@Module({
providers: [UserService] // Transient by default
})
Mark a class as injectable
This decorator wraps tsyringe's
@injectabledecorator and optionally associates a token with the class. The actual lifecycle (Singleton, Request, Transient) is determined at registration time, not decoration time.Lifecycle Control:
scope: Scope.Singletonin module providers for singletonscope: Scope.Requestin module providers for request-scoped