-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathconfig.module.ts
43 lines (40 loc) · 1008 Bytes
/
config.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { DynamicModule, Module, Global } from '@nestjs/common';
import { ConfigService, ConfigOptions } from './config.service';
@Global()
@Module({})
export class ConfigModule {
/**
* @param startPath
* @deprecated
*/
static resolveSrcPath(startPath: string): typeof ConfigModule {
ConfigService.resolveSrcPath(startPath);
return this;
}
/**
* @param path
*/
public static resolveRootPath(path: string): typeof ConfigModule {
ConfigService.resolveRootPath(path);
return this;
}
/**
* From Glob
* @param glob
* @param {ConfigOptions} options
* @returns {DynamicModule}
*/
static load(glob: string, options?: ConfigOptions): DynamicModule {
const configProvider = {
provide: ConfigService,
useFactory: async (): Promise<ConfigService> => {
return ConfigService.load(glob, options);
},
};
return {
module: ConfigModule,
providers: [configProvider],
exports: [configProvider],
};
}
}