Kind: Interface
Source: packages/common/serializer/class-serializer.interceptor.ts
Part of: Common
ClassSerializerInterceptorOptions configures the transformer implementation used by NestJS's ClassSerializerInterceptor. Its transformerPackage field allows applications to provide a compatible serialization package, such as class-transformer, when customizing response serialization behavior.
Properties
| Property | Type |
|---|---|
transformerPackage | TransformerPackage |
Diagram
mermaidgraph LR A[Controller Response] --> B[ClassSerializerInterceptor] B --> C[ClassSerializerInterceptorOptions] C --> D[transformerPackage] D --> E[Transformer Package] E --> F[Serialized HTTP Response]
Usage
tsimport { ClassSerializerInterceptor } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import * as classTransformer from 'class-transformer';
const serializerOptions = {
transformerPackage: classTransformer,
};
const serializerInterceptor = new ClassSerializerInterceptor(
new Reflector(),
serializerOptions,
);
// Register globally or apply with @UseInterceptors(serializerInterceptor).
AI Coding Instructions
- Provide a
transformerPackageimplementation compatible with the APIs expected byClassSerializerInterceptor. - Use
class-transformeras the standard package unless the application intentionally supplies an alternative compatible implementation. - Ensure the configured package is installed and available at runtime; missing transformer dependencies can break response serialization.
- Apply the interceptor globally or at controller/route level when serialized DTO output is required.
Used by
1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Injected or called by (1)
ClassSerializerInterceptor—packages/common/serializer/class-serializer.interceptor.ts:34
Was this page helpful?