@golevelup/nestjs-modules
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -6,2 +6,8 @@ # Change Log | ||
# [0.6.0](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-modules@0.5.0...@golevelup/nestjs-modules@0.6.0) (2022-07-16) | ||
### Features | ||
- **modules:** display compiler error on missing attributes at forRootAsync ([4fe3fec](https://github.com/golevelup/nestjs/commit/4fe3fecc98a249dbe23fb856493b34135064bef0)) | ||
# [0.5.0](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-modules@0.4.4...@golevelup/nestjs-modules@0.5.0) (2022-01-24) | ||
@@ -8,0 +14,0 @@ |
@@ -8,11 +8,13 @@ import { DynamicModule, Provider, Type } from '@nestjs/common'; | ||
} | ||
export interface AsyncModuleConfig<T> extends Pick<ModuleMetadata, 'imports' | 'exports'> { | ||
useExisting?: { | ||
export declare type AsyncModuleConfig<T> = Pick<ModuleMetadata, 'imports' | 'exports'> & ({ | ||
useExisting: { | ||
value: ModuleConfigFactory<T>; | ||
provide?: InjectionToken; | ||
}; | ||
useClass?: Type<ModuleConfigFactory<T>>; | ||
useFactory?: (...args: any[]) => Promise<T> | T; | ||
} | { | ||
useClass: Type<ModuleConfigFactory<T>>; | ||
} | { | ||
useFactory: (...args: any[]) => Promise<T> | T; | ||
inject?: any[]; | ||
} | ||
}); | ||
export declare function createModuleConfigProvider<T>(provide: InjectionToken, options: AsyncModuleConfig<T>): Provider[]; | ||
@@ -19,0 +21,0 @@ export interface IConfigurableDynamicRootModule<T, U> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConfigurableDynamicRootModule = exports.createModuleConfigProvider = void 0; | ||
const lodash_1 = require("lodash"); | ||
const rxjs_1 = require("rxjs"); | ||
const operators_1 = require("rxjs/operators"); | ||
function createModuleConfigProvider(provide, options) { | ||
if (options.useFactory) { | ||
var _a, _b; | ||
if ('useFactory' in options) { | ||
return [ | ||
@@ -13,7 +13,7 @@ { | ||
useFactory: options.useFactory, | ||
inject: options.inject || [], | ||
inject: (_a = options.inject) !== null && _a !== void 0 ? _a : [], | ||
}, | ||
]; | ||
} | ||
const optionsProvider = { | ||
const optionsProviderGenerator = (inject) => ({ | ||
provide, | ||
@@ -23,10 +23,7 @@ useFactory: async (moduleConfigFactory) => { | ||
}, | ||
inject: [ | ||
options.useClass || | ||
(0, lodash_1.get)(options, 'useExisting.provide', options.useExisting.value.constructor.name), | ||
], | ||
}; | ||
if (options.useClass) { | ||
inject: [inject], | ||
}); | ||
if ('useClass' in options) { | ||
return [ | ||
optionsProvider, | ||
optionsProviderGenerator(options.useClass), | ||
{ | ||
@@ -38,5 +35,5 @@ provide: options.useClass, | ||
} | ||
if (options.useExisting) { | ||
if ('useExisting' in options) { | ||
return [ | ||
optionsProvider, | ||
optionsProviderGenerator((_b = options.useExisting.provide) !== null && _b !== void 0 ? _b : options.useExisting.value.constructor.name), | ||
{ | ||
@@ -43,0 +40,0 @@ provide: options.useExisting.provide || |
{ | ||
"name": "@golevelup/nestjs-modules", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Reusable utilties to help level up NestJS Modules", | ||
@@ -56,3 +56,3 @@ "author": "Jesse Carter <jesse.r.carter@gmail.com>", | ||
}, | ||
"gitHead": "94ca5b66d3377ebf69b6ff22c1f3f38197fc553d" | ||
"gitHead": "2cc62bdaee59e7c4c7908475283c7d0b8765f2b4" | ||
} |
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
22803
140