@mondart/nestjs-common-module 1.1.49 → 1.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,5 +3,6 @@ import { CachingModuleAsyncOptions, CachingModuleOptions } from './caching.inter
|
|
|
3
3
|
export declare class CachingModule {
|
|
4
4
|
static register(options: CachingModuleOptions): DynamicModule;
|
|
5
5
|
static registerAsync(options: CachingModuleAsyncOptions): DynamicModule;
|
|
6
|
+
private static createAsyncOptionsProvider;
|
|
6
7
|
private static createAsyncProviders;
|
|
7
8
|
}
|
|
@@ -37,12 +37,14 @@ let CachingModule = CachingModule_1 = class CachingModule {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
static registerAsync(options) {
|
|
40
|
+
const asyncOptionsProvider = this.createAsyncOptionsProvider(options);
|
|
40
41
|
return {
|
|
41
42
|
module: CachingModule_1,
|
|
42
43
|
imports: [
|
|
43
44
|
...(options.imports || []),
|
|
45
|
+
asyncOptionsProvider,
|
|
44
46
|
cache_manager_1.CacheModule.registerAsync({
|
|
45
|
-
imports:
|
|
47
|
+
imports: [asyncOptionsProvider],
|
|
46
48
|
useFactory: async (cachingOptions) => ({
|
|
47
49
|
store: redisStore,
|
|
48
50
|
ttl: Number(cachingOptions.ttl),
|
|
@@ -54,10 +56,18 @@ let CachingModule = CachingModule_1 = class CachingModule {
|
|
|
54
56
|
inject: [caching_interface_1.CACHING_MODULE_OPTIONS],
|
|
55
57
|
}),
|
|
56
58
|
],
|
|
57
|
-
providers: [
|
|
59
|
+
providers: [caching_service_1.CachingService],
|
|
58
60
|
exports: [caching_service_1.CachingService, cache_manager_1.CacheModule],
|
|
59
61
|
};
|
|
60
62
|
}
|
|
63
|
+
static createAsyncOptionsProvider(options) {
|
|
64
|
+
const providers = this.createAsyncProviders(options);
|
|
65
|
+
return {
|
|
66
|
+
module: CachingModule_1,
|
|
67
|
+
providers,
|
|
68
|
+
exports: [caching_interface_1.CACHING_MODULE_OPTIONS],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
61
71
|
static createAsyncProviders(options) {
|
|
62
72
|
if (options.useFactory) {
|
|
63
73
|
return [
|