35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { Observable } from 'rxjs';
|
|
import { ExecutionContext } from './execution-context.interface';
|
|
/**
|
|
* Interface providing access to the response stream.
|
|
*
|
|
* @see [Interceptors](https://docs.nestjs.com/interceptors)
|
|
*
|
|
* @publicApi
|
|
*/
|
|
export interface CallHandler<T = any> {
|
|
/**
|
|
* Returns an `Observable` representing the response stream from the route
|
|
* handler.
|
|
*/
|
|
handle(): Observable<T>;
|
|
}
|
|
/**
|
|
* Interface describing implementation of an interceptor.
|
|
*
|
|
* @see [Interceptors](https://docs.nestjs.com/interceptors)
|
|
*
|
|
* @publicApi
|
|
*/
|
|
export interface NestInterceptor<T = any, R = any> {
|
|
/**
|
|
* Method to implement a custom interceptor.
|
|
*
|
|
* @param context an `ExecutionContext` object providing methods to access the
|
|
* route handler and class about to be invoked.
|
|
* @param next a reference to the `CallHandler`, which provides access to an
|
|
* `Observable` representing the response stream from the route handler.
|
|
*/
|
|
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<R> | Promise<Observable<R>>;
|
|
}
|