NestJS integration
NestJS support is built into the core package and exposed through the lombok-typescript/nestjs entry point. @nestjs/common and @nestjs/core are optional peer dependencies — nothing Nest-related is pulled in unless you import this subpath, so plain-TS users never see NestJS in their dependency tree.
Install
bash
npm install lombok-typescript @nestjs/common @nestjs/core reflect-metadataBootstrap
typescript
import { Module } from '@nestjs/common';
import { LombokModule } from 'lombok-typescript/nestjs';
@Module({
imports: [
LombokModule.forRoot({
logAdapter: 'nest',
defaultProviderScope: 'DEFAULT',
}),
],
})
export class AppModule {}Decorators
| Export | Purpose |
|---|---|
LombokModule.forRoot() | Global config token (LOMBOK_NEST_CONFIG) |
@LogNest | @Log using Nest Logger |
@MemoizeNest | @Memoize with REQUEST-scope guidance |
@RetryNest | @Retry with interceptor composition notes |
NEST_SCOPE_GUIDANCE | Scope advisory table |
Runnable example: examples/nestjs.
Provider scope
| Decorator | Recommended @Injectable scope | Notes |
|---|---|---|
@Singleton | DEFAULT | One instance per Nest container |
@Memoize / @MemoizeNest | REQUEST for per-request cache | Singleton + memoize can leak request data |
@Flyweight | DEFAULT | Pool is process-wide |
@Retry / @RetryNest | DEFAULT | Method-level; use interceptors for HTTP retry |
Interceptors
@RetryNest and @MemoizeNest run inside the method body. Nest HTTP interceptors wrap the handler pipeline — use both when you need transport-level and business-level policies.
See also: From Java Lombok, From class-validator.