• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ialopezg / corejs / #5

03 Nov 2023 08:38PM UTC coverage: 42.153% (-47.5%) from 89.623%
#5

push

ialopezg
feat: add microservice feature

10 of 84 branches covered (0.0%)

Branch coverage included in aggregate %.

49 of 77 new or added lines in 20 files covered. (63.64%)

155 existing lines in 21 files now uncovered.

221 of 464 relevant lines covered (47.63%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

19.23
/src/core/injector/loader.ts
1
import 'reflect-metadata';
1✔
2

3
import { IController, IInjectable } from '../../common/interfaces';
4
import { ModuleContainer } from './container';
5
import { Injector } from './injector';
1✔
6
import { LoggerService } from '../../common';
1✔
7
import { Module } from './module';
8
import { getInitializedModuleMessage } from '../helpers';
1✔
9

10
/**
11
 * Instance Loader.
12
 */
13
export class InstanceLoader {
1✔
NEW
14
  private readonly logger = new LoggerService(InstanceLoader.name);
×
NEW
15
  private injector = new Injector();
×
16

17
  /**
18
   * Creates a new instance of the class InstanceLoader.
19
   *
20
   * @param {ModuleContainer} container Modules container.
21
   */
NEW
22
  constructor(private readonly container: ModuleContainer) {}
×
23

24
  /**
25
   * Create the instances for all registered dependencies.
26
   */
27
  public initialize(): void {
UNCOV
28
    const modules = this.container.getModules();
×
29

UNCOV
30
    this.createPrototypes(modules);
×
UNCOV
31
    this.createInstances(modules);
×
32
  }
33

34
  private createPrototypes(modules: Map<string, Module>): void {
UNCOV
35
    modules.forEach((module, name) => {
×
UNCOV
36
      this.createPrototypesOfComponents(module);
×
UNCOV
37
      this.createPrototypesOfControllers(module);
×
38

NEW
39
      this.logger.log(getInitializedModuleMessage(name));
×
40
    });
41
  }
42

43
  private createInstances(modules: Map<string, Module>): void {
UNCOV
44
    modules.forEach((module) => {
×
UNCOV
45
      this.createInstancesOfComponents(module);
×
UNCOV
46
      this.createInstancesOfControllers(module);
×
47
    });
48
  }
49

50
  private createPrototypesOfComponents(parent: Module): void {
UNCOV
51
    parent.components.forEach((
×
52
      wrapper,
UNCOV
53
    ) => this.injector.loadPrototypeOfInstance<IInjectable>(
×
54
      wrapper.metaType,
55
      parent.components,
56
    ));
57
  }
58

59
  private createInstancesOfComponents(parent: Module): void {
UNCOV
60
    parent.components.forEach((
×
61
      wrapper,
UNCOV
62
    ) => this.injector.loadInstanceOfComponent(
×
63
      wrapper.metaType,
64
      parent,
65
    ));
66
  }
67

68
  private createPrototypesOfControllers(parent: Module): void {
UNCOV
69
    parent.controllers.forEach(
×
70
      (
71
        wrapper,
UNCOV
72
      ) => this.injector.loadPrototypeOfInstance<IController>(
×
73
        wrapper.metaType,
74
        parent.controllers,
75
      ));
76
  }
77

78
  private createInstancesOfControllers(parent: Module): void {
UNCOV
79
    parent.controllers.forEach(
×
80
      (
81
        wrapper,
UNCOV
82
      ) => this.injector.loadInstanceOfController(
×
83
        wrapper.metaType,
84
        parent,
85
      ));
86
  }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc