Commit 6f8d206 1 parent f665a19 commit 6f8d206 Copy full SHA for 6f8d206
File tree 1 file changed +11
-8
lines changed
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -250,21 +250,24 @@ export class NestFactoryStatic {
250
250
private createAdapterProxy < T > ( app : NestApplication , adapter : HttpServer ) : T {
251
251
const proxy = new Proxy ( app , {
252
252
get : ( receiver : Record < string , any > , prop : string ) => {
253
+ const mapToProxy = ( result : unknown ) => {
254
+ return result instanceof Promise
255
+ ? result . then ( mapToProxy )
256
+ : result instanceof NestApplication
257
+ ? proxy
258
+ : result ;
259
+ } ;
260
+
253
261
if ( ! ( prop in receiver ) && prop in adapter ) {
254
262
return ( ...args : unknown [ ] ) => {
255
- this . createExceptionZone ( adapter , prop ) ( ...args ) ;
256
- return proxy ;
263
+ const result = this . createExceptionZone ( adapter , prop ) ( ...args ) ;
264
+ return mapToProxy ( result ) ;
257
265
} ;
258
266
}
259
267
if ( isFunction ( receiver [ prop ] ) ) {
260
- const mapToProxy = ( result : unknown ) =>
261
- result instanceof NestApplication ? proxy : result ;
262
-
263
268
return ( ...args : unknown [ ] ) => {
264
269
const result = receiver [ prop ] ( ...args ) ;
265
- return result instanceof Promise
266
- ? result . then ( mapToProxy )
267
- : mapToProxy ( result ) ;
270
+ return mapToProxy ( result ) ;
268
271
} ;
269
272
}
270
273
return receiver [ prop ] ;
You can’t perform that action at this time.
0 commit comments