@golevelup/nestjs-discovery
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -6,2 +6,8 @@ # Change Log | ||
## [2.2.1](https://github.com/WonderPanda/nestjs-plus/compare/@golevelup/nestjs-discovery@2.2.0...@golevelup/nestjs-discovery@2.2.1) (2019-12-14) | ||
### Bug Fixes | ||
- **discovery:** discovery of components/providers in lazy way ([8a6fa7f](https://github.com/WonderPanda/nestjs-plus/commit/8a6fa7f)) | ||
# 2.2.0 (2019-11-09) | ||
@@ -8,0 +14,0 @@ |
@@ -19,4 +19,4 @@ import { ModulesContainer } from '@nestjs/core/injector/modules-container'; | ||
private readonly metadataScanner; | ||
private readonly discoveredControllers; | ||
private readonly discoveredProviders; | ||
private discoveredControllers?; | ||
private discoveredProviders?; | ||
constructor(modulesContainer: ModulesContainer, metadataScanner: MetadataScanner); | ||
@@ -70,3 +70,4 @@ /** | ||
private extractMethodMetaAtKey; | ||
private discover; | ||
} | ||
//# sourceMappingURL=discovery.service.d.ts.map |
@@ -49,15 +49,2 @@ "use strict"; | ||
this.metadataScanner = metadataScanner; | ||
const modulesMap = [...this.modulesContainer.entries()]; | ||
this.discoveredControllers = Promise.all(lodash_1.flatMap(modulesMap, ([key, nestModule]) => { | ||
const components = [...nestModule.routes.values()]; | ||
return components | ||
.filter(component => component.scope !== common_1.Scope.REQUEST) | ||
.map(component => this.toDiscoveredClass(nestModule, component)); | ||
})); | ||
this.discoveredProviders = Promise.all(lodash_1.flatMap(modulesMap, ([key, nestModule]) => { | ||
const components = [...nestModule.components.values()]; | ||
return components | ||
.filter(component => component.scope !== common_1.Scope.REQUEST) | ||
.map(component => this.toDiscoveredClass(nestModule, component)); | ||
})); | ||
} | ||
@@ -69,2 +56,5 @@ /** | ||
async providers(filter) { | ||
if (!this.discoveredProviders) { | ||
this.discoveredProviders = this.discover('providers'); | ||
} | ||
return (await this.discoveredProviders).filter(x => filter(x)); | ||
@@ -102,2 +92,5 @@ } | ||
async controllers(filter) { | ||
if (!this.discoveredControllers) { | ||
this.discoveredControllers = this.discover('controllers'); | ||
} | ||
return (await this.discoveredControllers).filter(x => filter(x)); | ||
@@ -179,2 +172,11 @@ } | ||
} | ||
async discover(component) { | ||
const modulesMap = [...this.modulesContainer.entries()]; | ||
return Promise.all(lodash_1.flatMap(modulesMap, ([key, nestModule]) => { | ||
const components = [...nestModule[component].values()]; | ||
return components | ||
.filter(component => component.scope !== common_1.Scope.REQUEST) | ||
.map(component => this.toDiscoveredClass(nestModule, component)); | ||
})); | ||
} | ||
}; | ||
@@ -181,0 +183,0 @@ DiscoveryService = __decorate([ |
{ | ||
"name": "@golevelup/nestjs-discovery", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A Badass NestJS module for querying your app's controllers, providers and handlers", | ||
@@ -51,3 +51,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f6eba82698bb356bb8a4c3cdddd070d7868a38fb" | ||
"gitHead": "a34a5bf28fa0c651c37fd62a47bab76bcda853d4" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33617
314