Skip to content

Commit d20f6bb

Browse files
chore(nestjs) publish 5.3.0 minor release
1 parent e8032f3 commit d20f6bb

63 files changed

Lines changed: 506 additions & 55 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare const CACHE_MANAGER = "CACHE_MANAGER";
2+
export declare const CACHE_MODULE_OPTIONS = "CACHE_MODULE_OPTIONS";
3+
export declare const CACHE_KEY_METADATA = "cache_module:cache_key";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.CACHE_MANAGER = 'CACHE_MANAGER';
4+
exports.CACHE_MODULE_OPTIONS = 'CACHE_MODULE_OPTIONS';
5+
exports.CACHE_KEY_METADATA = 'cache_module:cache_key';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { DynamicModule } from '../interfaces';
2+
import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-module.interface';
3+
export declare class CacheModule {
4+
static register(options?: CacheModuleOptions): DynamicModule;
5+
static registerAsync(options: CacheModuleAsyncOptions): DynamicModule;
6+
private static createAsyncProviders(options);
7+
private static createAsyncOptionsProvider(options);
8+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"use strict";
2+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6+
return c > 3 && r && Object.defineProperty(target, key, r), r;
7+
};
8+
Object.defineProperty(exports, "__esModule", { value: true });
9+
const decorators_1 = require("../decorators");
10+
const cache_constants_1 = require("./cache.constants");
11+
const cache_providers_1 = require("./cache.providers");
12+
let CacheModule = CacheModule_1 = class CacheModule {
13+
static register(options = {}) {
14+
return {
15+
module: CacheModule_1,
16+
providers: [{ provide: cache_constants_1.CACHE_MODULE_OPTIONS, useValue: options }],
17+
};
18+
}
19+
static registerAsync(options) {
20+
return {
21+
module: CacheModule_1,
22+
imports: options.imports,
23+
providers: this.createAsyncProviders(options),
24+
};
25+
}
26+
static createAsyncProviders(options) {
27+
if (options.useExisting || options.useFactory) {
28+
return [this.createAsyncOptionsProvider(options)];
29+
}
30+
return [
31+
this.createAsyncOptionsProvider(options),
32+
{
33+
provide: options.useClass,
34+
useClass: options.useClass,
35+
},
36+
];
37+
}
38+
static createAsyncOptionsProvider(options) {
39+
if (options.useFactory) {
40+
return {
41+
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
42+
useFactory: options.useFactory,
43+
inject: options.inject || [],
44+
};
45+
}
46+
return {
47+
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
48+
useFactory: async (optionsFactory) => await optionsFactory.createCacheOptions(),
49+
inject: [options.useExisting || options.useClass],
50+
};
51+
}
52+
};
53+
CacheModule = CacheModule_1 = __decorate([
54+
decorators_1.Module({
55+
providers: [cache_providers_1.createCacheManager()],
56+
exports: [cache_constants_1.CACHE_MANAGER],
57+
})
58+
], CacheModule);
59+
exports.CacheModule = CacheModule;
60+
var CacheModule_1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Provider } from '../interfaces';
2+
export declare function createCacheManager(): Provider;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const load_package_util_1 = require("../utils/load-package.util");
4+
const cache_constants_1 = require("./cache.constants");
5+
const default_options_1 = require("./default-options");
6+
function createCacheManager() {
7+
return {
8+
provide: cache_constants_1.CACHE_MANAGER,
9+
useFactory: (options) => {
10+
const cacheManager = load_package_util_1.loadPackage('cache-manager', 'CacheModule');
11+
const memoryCache = cacheManager.caching(Object.assign({}, default_options_1.defaultCacheOptions, (options || {})));
12+
return memoryCache;
13+
},
14+
inject: [cache_constants_1.CACHE_MODULE_OPTIONS],
15+
};
16+
}
17+
exports.createCacheManager = createCacheManager;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare const CacheKey: (key: string) => (target: object, key?: any, descriptor?: any) => any;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const decorators_1 = require("../../decorators");
4+
const cache_constants_1 = require("../cache.constants");
5+
exports.CacheKey = (key) => decorators_1.ReflectMetadata(cache_constants_1.CACHE_KEY_METADATA, key);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './cache-key.decorator';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
function __export(m) {
3+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4+
}
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
__export(require("./cache-key.decorator"));

0 commit comments

Comments
 (0)