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

Method reflectInjectables

packages/core/scanner.ts:297–347  ·  view source on GitHub ↗
(
    component: Type<Injectable>,
    token: string,
    metadataKey: string,
  )

Source from the content-addressed store, hash-verified

295 }
296
297 public reflectInjectables(
298 component: Type<Injectable>,
299 token: string,
300 metadataKey: string,
301 ) {
302 const controllerInjectables = this.reflectMetadata<Type<Injectable>>(
303 metadataKey,
304 component,
305 );
306 const methodInjectables = this.metadataScanner
307 .getAllMethodNames(component.prototype)
308 .reduce(
309 (acc, method) => {
310 const methodInjectable = this.reflectKeyMetadata(
311 component,
312 metadataKey,
313 method,
314 );
315
316 if (methodInjectable) {
317 acc.push(methodInjectable);
318 }
319
320 return acc;
321 },
322 [] as Array<{
323 methodKey: string;
324 metadata: Type<Injectable>[];
325 }>,
326 );
327
328 controllerInjectables.forEach(injectable =>
329 this.insertInjectable(
330 injectable,
331 token,
332 component,
333 ENHANCER_KEY_TO_SUBTYPE_MAP[metadataKey],
334 ),
335 );
336 methodInjectables.forEach(methodInjectable => {
337 methodInjectable.metadata.forEach(injectable =>
338 this.insertInjectable(
339 injectable,
340 token,
341 component,
342 ENHANCER_KEY_TO_SUBTYPE_MAP[metadataKey],
343 methodInjectable.methodKey,
344 ),
345 );
346 });
347 }
348
349 public reflectParamInjectables(
350 component: Type<Injectable>,

Callers 1

Calls 4

reflectMetadataMethod · 0.95
reflectKeyMetadataMethod · 0.95
insertInjectableMethod · 0.95
getAllMethodNamesMethod · 0.80

Tested by

no test coverage detected