From 577cb2b9afc1acb2b7e9846e5745a9f252823f66 Mon Sep 17 00:00:00 2001 From: "Micael Levi L. Cavalcante" Date: Sat, 30 Dec 2023 15:16:17 -0400 Subject: [PATCH 1/2] chore: ship line comments --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 519fca1..5b75837 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "declaration": true, - "removeComments": true, + "removeComments": false, "noLib": false, "emitDecoratorMetadata": true, "esModuleInterop": true, From ac439925f79bf728443922c31f49cb63082fd0e2 Mon Sep 17 00:00:00 2001 From: "Micael Levi L. Cavalcante" Date: Sat, 30 Dec 2023 15:18:00 -0400 Subject: [PATCH 2/2] feat: expose cache manager provider as a wrapper class for cache-manager --- lib/cache.module.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/cache.module.ts b/lib/cache.module.ts index a525371..0d8ddf5 100644 --- a/lib/cache.module.ts +++ b/lib/cache.module.ts @@ -1,4 +1,5 @@ import { DynamicModule, Module } from '@nestjs/common'; +import type { Cache as CoreCache } from 'cache-manager' import { CACHE_MANAGER } from './cache.constants'; import { ConfigurableModuleClass } from './cache.module-definition'; import { createCacheManager } from './cache.providers'; @@ -7,6 +8,15 @@ import { CacheModuleOptions, } from './interfaces/cache-module.interface'; +/** + * This is just the same as the `Cache` interface from `cache-manager` but you can + * use this as a provider token as well. + */ +// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging +export abstract class Cache {} +// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging +export interface Cache extends CoreCache {} + /** * Module that provides Nest cache-manager. * @@ -15,8 +25,14 @@ import { * @publicApi */ @Module({ - providers: [createCacheManager()], - exports: [CACHE_MANAGER], + providers: [ + createCacheManager(), + { + provide: Cache, + useExisting: CACHE_MANAGER, + } + ], + exports: [CACHE_MANAGER, Cache], }) export class CacheModule extends ConfigurableModuleClass { /**