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

Method setModule

packages/core/injector/container.ts:163–185  ·  view source on GitHub ↗
(
    { token, dynamicMetadata, type }: ModuleFactory,
    scope: ModuleScope,
  )

Source from the content-addressed store, hash-verified

161 }
162
163 private async setModule(
164 { token, dynamicMetadata, type }: ModuleFactory,
165 scope: ModuleScope,
166 ): Promise<Module> {
167 const moduleRef = new Module(type, this);
168 moduleRef.token = token;
169 moduleRef.initOnPreview = this.shouldInitOnPreview(type);
170 this.modules.set(token, moduleRef);
171
172 const updatedScope = ([] as ModuleScope).concat(scope, type);
173 await this.addDynamicMetadata(token, dynamicMetadata!, updatedScope);
174
175 if (this.isGlobalModule(type, dynamicMetadata)) {
176 moduleRef.isGlobal = true;
177
178 // Set global module distance to MAX_VALUE to ensure their lifecycle hooks
179 // are always executed first (when initializing the application)
180 moduleRef.distance = Number.MAX_VALUE;
181 this.addGlobalModule(moduleRef);
182 }
183
184 return moduleRef;
185 }
186
187 public async addDynamicMetadata(
188 token: string,

Callers 2

addModuleMethod · 0.95
replaceModuleMethod · 0.95

Calls 5

shouldInitOnPreviewMethod · 0.95
addDynamicMetadataMethod · 0.95
isGlobalModuleMethod · 0.95
addGlobalModuleMethod · 0.95
setMethod · 0.65

Tested by

no test coverage detected