UNPKG

1.1 kBTypeScriptView Raw
1import { Observable } from 'rxjs';
2import { ExecutionContext } from './execution-context.interface';
3/**
4 * Interface providing access to the response stream.
5 *
6 * @see [Interceptors](https://docs.nestjs.com/interceptors)
7 *
8 * @publicApi
9 */
10export interface CallHandler<T = any> {
11 /**
12 * Returns an `Observable` representing the response stream from the route
13 * handler.
14 */
15 handle(): Observable<T>;
16}
17/**
18 * Interface describing implementation of an interceptor.
19 *
20 * @see [Interceptors](https://docs.nestjs.com/interceptors)
21 *
22 * @publicApi
23 */
24export interface NestInterceptor<T = any, R = any> {
25 /**
26 * Method to implement a custom interceptor.
27 *
28 * @param context an `ExecutionContext` object providing methods to access the
29 * route handler and class about to be invoked.
30 * @param next a reference to the `CallHandler`, which provides access to an
31 * `Observable` representing the response stream from the route handler.
32 */
33 intercept(context: ExecutionContext, next: CallHandler<T>): Observable<R> | Promise<Observable<R>>;
34}