File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11import { DynamicModule , Module } from '@nestjs/common' ;
2+ import type { Cache as CoreCache } from 'cache-manager'
23import { CACHE_MANAGER } from './cache.constants' ;
34import { ConfigurableModuleClass } from './cache.module-definition' ;
45import { createCacheManager } from './cache.providers' ;
@@ -7,6 +8,15 @@ import {
78 CacheModuleOptions ,
89} from './interfaces/cache-module.interface' ;
910
11+ /**
12+ * This is just the same as the `Cache` interface from `cache-manager` but you can
13+ * use this as a provider token as well.
14+ */
15+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
16+ export abstract class Cache { }
17+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
18+ export interface Cache extends CoreCache { }
19+
1020/**
1121 * Module that provides Nest cache-manager.
1222 *
@@ -15,8 +25,14 @@ import {
1525 * @publicApi
1626 */
1727@Module ( {
18- providers : [ createCacheManager ( ) ] ,
19- exports : [ CACHE_MANAGER ] ,
28+ providers : [
29+ createCacheManager ( ) ,
30+ {
31+ provide : Cache ,
32+ useExisting : CACHE_MANAGER ,
33+ }
34+ ] ,
35+ exports : [ CACHE_MANAGER , Cache ] ,
2036} )
2137export class CacheModule extends ConfigurableModuleClass {
2238 /**
Original file line number Diff line number Diff line change 22 "compilerOptions" : {
33 "module" : " commonjs" ,
44 "declaration" : true ,
5- "removeComments" : true ,
5+ "removeComments" : false ,
66 "noLib" : false ,
77 "emitDecoratorMetadata" : true ,
88 "esModuleInterop" : true ,
You can’t perform that action at this time.
0 commit comments