Kind: Class
Source: packages/microservices/deserializers/identity.deserializer.ts
Part of: Microservices
IdentityDeserializer is a pass-through microservice deserializer that returns incoming message data without transforming it. It is useful when a transport adapter already provides data in the format expected by the application and no custom parsing or normalization is required.
Implements: Deserializer
Methods
| Method | Signature | Returns |
|---|---|---|
deserialize | deserialize(value: any) | void |
Diagram
mermaidgraph LR A[Microservice Transport] --> B[Incoming Message] B --> C[IdentityDeserializer] C --> D[deserialize()] D --> E[Original Message Value] E --> F[Message Handler]
Usage
tsimport { IdentityDeserializer } from '@nestjs/microservices';
const deserializer = new IdentityDeserializer();
const incomingMessage = {
pattern: 'user.created',
data: {
id: 'user-123',
email: 'user@example.com',
},
};
const result = deserializer.deserialize(incomingMessage);
console.log(result === incomingMessage); // true
AI Coding Instructions
- Use
IdentityDeserializerwhen transport payloads should be passed directly to message handlers without parsing or transformation. - Do not add validation, serialization, or cloning logic here; use a custom deserializer when payload normalization is required.
- Ensure the configured microservice transport produces payloads compatible with the consuming handler's expected shape.
- Configure this deserializer through the microservice transport options when replacing a transport-specific or custom deserialization strategy.
Was this page helpful?