UNPKG

1.6 kBTypeScriptView Raw
1import { ModuleMetadata, Provider, Type } from '../../interfaces';
2import { CacheManagerOptions } from './cache-manager.interface';
3export interface CacheModuleOptions extends CacheManagerOptions {
4 [key: string]: any;
5}
6/**
7 * Interface describing a `CacheOptionsFactory`. Providers supplying configuration
8 * options for the Cache module must implement this interface.
9 *
10 * @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
11 *
12 * @publicApi
13 */
14export interface CacheOptionsFactory {
15 createCacheOptions(): Promise<CacheModuleOptions> | CacheModuleOptions;
16}
17/**
18 * Options for dynamically configuring the Cache module.
19 *
20 * @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
21 *
22 * @publicApi
23 */
24export interface CacheModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
25 /**
26 * Injection token resolving to an existing provider. The provider must implement
27 * the `CacheOptionsFactory` interface.
28 */
29 useExisting?: Type<CacheOptionsFactory>;
30 /**
31 * Injection token resolving to a class that will be instantiated as a provider.
32 * The class must implement the `CacheOptionsFactory` interface.
33 */
34 useClass?: Type<CacheOptionsFactory>;
35 /**
36 * Function returning options (or a Promise resolving to options) to configure the
37 * cache module.
38 */
39 useFactory?: (...args: any[]) => Promise<CacheModuleOptions> | CacheModuleOptions;
40 /**
41 * Dependencies that a Factory may inject.
42 */
43 inject?: any[];
44 extraProviders?: Provider[];
45}