UNPKG

2.94 kBTypeScriptView Raw
1import { HttpServer } from '@nestjs/common';
2import { RequestMethod } from '@nestjs/common/enums/request-method.enum';
3import { Controller } from '@nestjs/common/interfaces/controllers/controller.interface';
4import { Type } from '@nestjs/common/interfaces/type.interface';
5import { VersionValue } from '@nestjs/common/interfaces/version-options.interface';
6import { ApplicationConfig } from '../application-config';
7import { NestContainer } from '../injector/container';
8import { Injector } from '../injector/injector';
9import { InstanceWrapper } from '../injector/instance-wrapper';
10import { Module } from '../injector/module';
11import { MetadataScanner } from '../metadata-scanner';
12import { ExceptionsFilter } from './interfaces/exceptions-filter.interface';
13import { RoutePathMetadata } from './interfaces/route-path-metadata.interface';
14import { RoutePathFactory } from './route-path-factory';
15import { RouterProxy, RouterProxyCallback } from './router-proxy';
16export interface RouteDefinition {
17 path: string[];
18 requestMethod: RequestMethod;
19 targetCallback: RouterProxyCallback;
20 methodName: string;
21 version?: VersionValue;
22}
23export declare class RouterExplorer {
24 private readonly metadataScanner;
25 private readonly container;
26 private readonly injector?;
27 private readonly routerProxy?;
28 private readonly exceptionsFilter?;
29 private readonly config?;
30 private readonly routePathFactory?;
31 private readonly executionContextCreator;
32 private readonly routerMethodFactory;
33 private readonly logger;
34 private readonly exceptionFiltersCache;
35 constructor(metadataScanner: MetadataScanner, container: NestContainer, injector?: Injector, routerProxy?: RouterProxy, exceptionsFilter?: ExceptionsFilter, config?: ApplicationConfig, routePathFactory?: RoutePathFactory);
36 explore<T extends HttpServer = any>(instanceWrapper: InstanceWrapper, moduleKey: string, applicationRef: T, host: string | RegExp | Array<string | RegExp>, routePathMetadata: RoutePathMetadata): void;
37 extractRouterPath(metatype: Type<Controller>): string[];
38 scanForPaths(instance: Controller, prototype?: object): RouteDefinition[];
39 exploreMethodMetadata(instance: Controller, prototype: object, methodName: string): RouteDefinition;
40 applyPathsToRouterProxy<T extends HttpServer>(router: T, routeDefinitions: RouteDefinition[], instanceWrapper: InstanceWrapper, moduleKey: string, routePathMetadata: RoutePathMetadata, host: string | RegExp | Array<string | RegExp>): void;
41 private applyCallbackToRouter;
42 private applyHostFilter;
43 private applyVersionFilter;
44 private createCallbackProxy;
45 createRequestScopedHandler(instanceWrapper: InstanceWrapper, requestMethod: RequestMethod, moduleRef: Module, moduleKey: string, methodName: string): <TRequest extends Record<any, any>, TResponse>(req: TRequest, res: TResponse, next: () => void) => Promise<void>;
46 private getContextId;
47}