Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MiddlewareBuilder

Hierarchy

  • MiddlewareBuilder

Implements

  • MiddlewareConsumer

Index

Constructors

constructor

Properties

Private Readonly httpAdapter

httpAdapter: HttpServer

Private Readonly middlewareCollection

middlewareCollection: Set<MiddlewareConfiguration<any>> = new Set<MiddlewareConfiguration>()

Private Readonly routesMapper

routesMapper: RoutesMapper

Static Private Readonly ConfigProxy

ConfigProxy: (Anonymous class) = class implements MiddlewareConfigProxy {private excludedRoutes: RouteInfo[] = [];constructor(private readonly builder: MiddlewareBuilder,private readonly middleware: Array<Type<any> | Function | any>,) {}public getExcludedRoutes(): RouteInfo[] {return this.excludedRoutes;}public exclude(...routes: Array<string | RouteInfo>): MiddlewareConfigProxy {this.excludedRoutes = this.getRoutesFlatList(routes);return this;}public forRoutes(...routes: Array<string | Type<any> | RouteInfo>): MiddlewareConsumer {const { middlewareCollection } = this.builder;const forRoutes = this.getRoutesFlatList(routes);const configuration = {middleware: filterMiddleware(this.middleware,this.excludedRoutes,this.builder.getHttpAdapter(),),forRoutes,};middlewareCollection.add(configuration);return this.builder;}private getRoutesFlatList(routes: Array<string | Type<any> | RouteInfo>,): RouteInfo[] {const { routesMapper } = this.builder;return iterate(routes).map(route => routesMapper.mapRouteToRouteInfo(route)).flatten().toArray();}}

Methods

apply

  • apply(...middleware: Array<Type<any> | Function | any>): MiddlewareConfigProxy

build

  • build(): MiddlewareConfiguration[]

getHttpAdapter

  • getHttpAdapter(): HttpServer

Generated using TypeDoc