Skip to content

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-metadata

Bootstrap

typescript
import { Module } from '@nestjs/common';
import { LombokModule } from 'lombok-typescript/nestjs';

@Module({
  imports: [
    LombokModule.forRoot({
      logAdapter: 'nest',
      defaultProviderScope: 'DEFAULT',
    }),
  ],
})
export class AppModule {}

Decorators

ExportPurpose
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_GUIDANCEScope advisory table

Runnable example: examples/nestjs.

Provider scope

DecoratorRecommended @Injectable scopeNotes
@SingletonDEFAULTOne instance per Nest container
@Memoize / @MemoizeNestREQUEST for per-request cacheSingleton + memoize can leak request data
@FlyweightDEFAULTPool is process-wide
@Retry / @RetryNestDEFAULTMethod-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.

Released under the MIT License.