UNPKG

4.14 kBTypeScriptView Raw
1import { CanActivate, HttpServer, ParamData, PipeTransform, RequestMethod } from '@nestjs/common';
2import { RouteParamMetadata } from '@nestjs/common/decorators';
3import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
4import { ContextType, Controller } from '@nestjs/common/interfaces';
5import { GuardsConsumer } from '../guards/guards-consumer';
6import { GuardsContextCreator } from '../guards/guards-context-creator';
7import { ExecutionContextHost } from '../helpers/execution-context-host';
8import { HandleResponseFn, HandlerMetadata } from '../helpers/handler-metadata-storage';
9import { InterceptorsConsumer } from '../interceptors/interceptors-consumer';
10import { InterceptorsContextCreator } from '../interceptors/interceptors-context-creator';
11import { PipesConsumer } from '../pipes/pipes-consumer';
12import { PipesContextCreator } from '../pipes/pipes-context-creator';
13import { IRouteParamsFactory } from './interfaces/route-params-factory.interface';
14import { CustomHeader, RedirectResponse } from './router-response-controller';
15export interface ParamProperties {
16 index: number;
17 type: RouteParamtypes | string;
18 data: ParamData;
19 pipes: PipeTransform[];
20 extractValue: <TRequest, TResponse>(req: TRequest, res: TResponse, next: Function) => any;
21}
22export declare class RouterExecutionContext {
23 private readonly paramsFactory;
24 private readonly pipesContextCreator;
25 private readonly pipesConsumer;
26 private readonly guardsContextCreator;
27 private readonly guardsConsumer;
28 private readonly interceptorsContextCreator;
29 private readonly interceptorsConsumer;
30 readonly applicationRef: HttpServer;
31 private readonly handlerMetadataStorage;
32 private readonly contextUtils;
33 private readonly responseController;
34 constructor(paramsFactory: IRouteParamsFactory, pipesContextCreator: PipesContextCreator, pipesConsumer: PipesConsumer, guardsContextCreator: GuardsContextCreator, guardsConsumer: GuardsConsumer, interceptorsContextCreator: InterceptorsContextCreator, interceptorsConsumer: InterceptorsConsumer, applicationRef: HttpServer);
35 create(instance: Controller, callback: (...args: any[]) => unknown, methodName: string, moduleKey: string, requestMethod: RequestMethod, contextId?: import("..").ContextId, inquirerId?: string): <TRequest, TResponse>(req: TRequest, res: TResponse, next: Function) => Promise<void>;
36 getMetadata<TContext extends ContextType = ContextType>(instance: Controller, callback: (...args: any[]) => any, methodName: string, moduleKey: string, requestMethod: RequestMethod, contextType: TContext): HandlerMetadata;
37 reflectRedirect(callback: (...args: unknown[]) => unknown): RedirectResponse;
38 reflectHttpStatusCode(callback: (...args: unknown[]) => unknown): number;
39 reflectRenderTemplate(callback: (...args: unknown[]) => unknown): string;
40 reflectResponseHeaders(callback: (...args: unknown[]) => unknown): CustomHeader[];
41 reflectSse(callback: (...args: unknown[]) => unknown): string;
42 exchangeKeysForValues(keys: string[], metadata: Record<number, RouteParamMetadata>, moduleContext: string, contextId?: import("..").ContextId, inquirerId?: string, contextFactory?: (args: unknown[]) => ExecutionContextHost): ParamProperties[];
43 getParamValue<T>(value: T, { metatype, type, data, }: {
44 metatype: unknown;
45 type: RouteParamtypes;
46 data: unknown;
47 }, pipes: PipeTransform[]): Promise<unknown>;
48 isPipeable(type: number | string): boolean;
49 createGuardsFn<TContext extends string = ContextType>(guards: CanActivate[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): (args: any[]) => Promise<void> | null;
50 createPipesFn(pipes: PipeTransform[], paramsOptions: (ParamProperties & {
51 metatype?: any;
52 })[]): <TRequest, TResponse>(args: any[], req: TRequest, res: TResponse, next: Function) => Promise<void>;
53 createHandleResponseFn(callback: (...args: unknown[]) => unknown, isResponseHandled: boolean, redirectResponse?: RedirectResponse, httpStatusCode?: number): HandleResponseFn;
54 private isResponseHandled;
55}