19 lines
430 B
TypeScript
19 lines
430 B
TypeScript
|
|
import {
|
||
|
|
Injectable,
|
||
|
|
NestInterceptor,
|
||
|
|
ExecutionContext,
|
||
|
|
CallHandler,
|
||
|
|
RequestTimeoutException,
|
||
|
|
} from '@nestjs/common';
|
||
|
|
import { Observable } from 'rxjs';
|
||
|
|
import { timeout } from 'rxjs/operators';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class TimeoutInterceptor implements NestInterceptor {
|
||
|
|
intercept(_context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
||
|
|
return next.handle().pipe(
|
||
|
|
timeout(30000),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|