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

Method addProvider

packages/core/injector/container.ts:252–270  ·  view source on GitHub ↗
(
    provider: Provider,
    token: string,
    enhancerSubtype?: EnhancerSubtype,
  )

Source from the content-addressed store, hash-verified

250 }
251
252 public addProvider(
253 provider: Provider,
254 token: string,
255 enhancerSubtype?: EnhancerSubtype,
256 ): string | symbol | Function {
257 const moduleRef = this.modules.get(token);
258 if (!provider) {
259 throw new CircularDependencyException(moduleRef?.metatype.name);
260 }
261 if (!moduleRef) {
262 throw new UnknownModuleException();
263 }
264 const providerKey = moduleRef.addProvider(provider, enhancerSubtype!);
265 const providerRef = moduleRef.getProviderByKey(providerKey);
266
267 DiscoverableMetaHostCollection.inspectProvider(this.modules, providerRef);
268
269 return providerKey as Function;
270 }
271
272 public addInjectable(
273 injectable: Provider,

Callers 1

testHelperFunction · 0.95

Calls 3

getProviderByKeyMethod · 0.80
inspectProviderMethod · 0.80
getMethod · 0.65

Tested by 1

testHelperFunction · 0.76