About Interceptors
Request/response transformation interceptors
Browse the snippets below to find the interceptors implementation you need for your NestJS project.
All Interceptors Snippets
Transform Interceptor
Wrap responses in consistent format
- Consistent response format
- Timestamp and path included
- @SkipTransform decorator
Serialize Interceptor
Response serialization with DTOs
- @Serialize decorator
- DTO-based serialization
- Excludes sensitive fields
Logging Interceptor
Request/response logging
- Duration tracking
- Sensitive data masking
- Status-based log levels
Timeout Interceptor
Request timeout handling
- Configurable timeout
- @Timeout decorator
- Custom error message
Cache Interceptor
Response caching with TTL
- @CacheTTL decorator
- @NoCache decorator
- Key generation
How to Use
Install any snippet using the Hanma CLI:
npx hanma add --framework nest
For example, to install the first snippet:
npx hanma add transform-interceptor --framework nest