1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DiscoveryService = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const common_1 = require("@nestjs/common");
|
6 | const modules_container_1 = require("../injector/modules-container");
|
7 |
|
8 |
|
9 |
|
10 | let DiscoveryService = class DiscoveryService {
|
11 | constructor(modulesContainer) {
|
12 | this.modulesContainer = modulesContainer;
|
13 | }
|
14 | getProviders(options = {}, modules = this.getModules(options)) {
|
15 | const providers = modules.map(item => [...item.providers.values()]);
|
16 | return (0, common_1.flatten)(providers);
|
17 | }
|
18 | getControllers(options = {}, modules = this.getModules(options)) {
|
19 | const controllers = modules.map(item => [...item.controllers.values()]);
|
20 | return (0, common_1.flatten)(controllers);
|
21 | }
|
22 | getModules(options = {}) {
|
23 | if (!options.include) {
|
24 | const moduleRefs = [...this.modulesContainer.values()];
|
25 | return moduleRefs;
|
26 | }
|
27 | const whitelisted = this.includeWhitelisted(options.include);
|
28 | return whitelisted;
|
29 | }
|
30 | includeWhitelisted(include) {
|
31 | const moduleRefs = [...this.modulesContainer.values()];
|
32 | return moduleRefs.filter(({ metatype }) => include.some(item => item === metatype));
|
33 | }
|
34 | };
|
35 | DiscoveryService = tslib_1.__decorate([
|
36 | (0, common_1.Injectable)(),
|
37 | tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
38 | ], DiscoveryService);
|
39 | exports.DiscoveryService = DiscoveryService;
|