@@ -78,9 +78,9 @@ export class EndpointsFactory<
7878 CIN extends IOSchema | undefined ,
7979 COUT extends FlatObject ,
8080 CSCO extends string ,
81- > ( middlewares : AbstractMiddleware [ ] ) {
81+ > ( middleware : AbstractMiddleware ) {
8282 const factory = new EndpointsFactory < CIN , COUT , CSCO > ( this . resultHandler ) ;
83- factory . middlewares = middlewares ;
83+ factory . middlewares = this . middlewares . concat ( middleware ) ;
8484 return factory ;
8585 }
8686
@@ -97,11 +97,7 @@ export class EndpointsFactory<
9797 ConditionalIntersection < IN , AIN > ,
9898 OUT & AOUT ,
9999 SCO & ASCO
100- > (
101- this . middlewares . concat (
102- subject instanceof Middleware ? subject : new Middleware ( subject ) ,
103- ) ,
104- ) ;
100+ > ( subject instanceof Middleware ? subject : new Middleware ( subject ) ) ;
105101 }
106102
107103 public use = this . addExpressMiddleware ;
@@ -111,14 +107,12 @@ export class EndpointsFactory<
111107 S extends Response ,
112108 AOUT extends FlatObject = EmptyObject ,
113109 > ( ...params : ConstructorParameters < typeof ExpressMiddleware < R , S , AOUT > > ) {
114- return this . #create< IN , OUT & AOUT , SCO > (
115- this . middlewares . concat ( new ExpressMiddleware ( ...params ) ) ,
116- ) ;
110+ return this . #create< IN , OUT & AOUT , SCO > ( new ExpressMiddleware ( ...params ) ) ;
117111 }
118112
119113 public addOptions < AOUT extends FlatObject > ( getOptions : ( ) => Promise < AOUT > ) {
120114 return this . #create< IN , OUT & AOUT , SCO > (
121- this . middlewares . concat ( new Middleware ( { handler : getOptions } ) ) ,
115+ new Middleware ( { handler : getOptions } ) ,
122116 ) ;
123117 }
124118
0 commit comments