MCPcopy
hub / github.com/nestjs/nest / createAdapterProxy

Method createAdapterProxy

packages/core/nest-factory.ts:350–377  ·  view source on GitHub ↗
(app: NestApplication, adapter: HttpServer)

Source from the content-addressed store, hash-verified

348 }
349
350 private createAdapterProxy<T>(app: NestApplication, adapter: HttpServer): T {
351 const proxy = new Proxy(app, {
352 get: (receiver: Record<string, any>, prop: string) => {
353 const mapToProxy = (result: unknown) => {
354 return result instanceof Promise
355 ? result.then(mapToProxy)
356 : result instanceof NestApplication
357 ? proxy
358 : result;
359 };
360
361 if (!(prop in receiver) && prop in adapter) {
362 return (...args: unknown[]) => {
363 const result = this.createExceptionZone(adapter, prop)(...args);
364 return mapToProxy(result);
365 };
366 }
367 if (isFunction(receiver[prop])) {
368 return (...args: unknown[]) => {
369 const result = receiver[prop](...args);
370 return mapToProxy(result);
371 };
372 }
373 return receiver[prop];
374 },
375 });
376 return proxy as unknown as T;
377 }
378
379 private createGraphInspector(
380 appOptions: NestApplicationContextOptions,

Callers 1

createMethod · 0.95

Calls 2

createExceptionZoneMethod · 0.95
isFunctionFunction · 0.90

Tested by

no test coverage detected