16 lines
459 B
TypeScript
16 lines
459 B
TypeScript
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
|
|
import { map, Observable } from 'rxjs';
|
|
|
|
@Injectable()
|
|
export class ResponseInterceptor<T> implements NestInterceptor<T, any> {
|
|
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<any> {
|
|
return next.handle().pipe(
|
|
map(data => ({
|
|
success: true,
|
|
data,
|
|
timestamp: new Date().toISOString(),
|
|
})),
|
|
);
|
|
}
|
|
}
|