nestjs 주입 에 의존 하 는 Injector 클래스

1003 단어 #nest.js
src/core/injector/injector.ts

//   ,    
export class Injector {
  //       
  public async loadInstanceOfMiddleware(
    wrapper: MiddlewareWrapper,
    collection: Map,
    module: Module) {
    //     
    const { metatype } = wrapper;
    //      
    const currentMetatype = collection.get(metatype.name);
    //           ,    
    if (currentMetatype.instance !== null) return;
    //       ,        ,               ,            
    await this.resolveConstructorParams(wrapper as any, module, null, null, (instances) => {
      collection.set(metatype.name, {
        instance: new metatype(...instances),
        metatype,
      });
    });
  }

  //       
  public async loadInstanceOfRoute(wrapper: InstanceWrapper, module: Module) {
    //     Map
    const routes = module.routes;
    //            
    await this.loadInstance(wrapper, routes, module);
  }

  //        
 

좋은 웹페이지 즐겨찾기