1
1
import { ApolloDriver , ApolloDriverConfig } from '@nestjs/apollo' ;
2
2
import { Module } from '@nestjs/common' ;
3
- import { ConfigModule } from '@nestjs/config' ;
3
+ import { ConfigModule , ConfigService } from '@nestjs/config' ;
4
4
import { GraphQLModule } from '@nestjs/graphql' ;
5
5
import { TypeOrmModule } from '@nestjs/typeorm' ;
6
6
7
7
import { AuthModule } from './auth/auth.module' ;
8
8
import { CustomCacheModule } from './cache/custom-cache.module' ;
9
+ import {
10
+ typeormConfigKey ,
11
+ typeormConfigLoader ,
12
+ } from './common/config/ormconfig' ;
9
13
import { getEnvPath } from './common/helper/env.helper' ;
10
14
import { envValidation } from './common/helper/env.validation' ;
11
15
import { SettingModule } from './common/shared/setting/setting.module' ;
@@ -19,6 +23,7 @@ import { UserModule } from './user/user.module';
19
23
ConfigModule . forRoot ( {
20
24
envFilePath : getEnvPath ( `${ __dirname } /..` ) ,
21
25
validate : envValidation ,
26
+ load : [ typeormConfigLoader ] ,
22
27
} ) ,
23
28
GraphQLModule . forRootAsync < ApolloDriverConfig > ( {
24
29
driver : ApolloDriver ,
@@ -28,10 +33,10 @@ import { UserModule } from './user/user.module';
28
33
settingService . graphqlUseFactory ,
29
34
} ) ,
30
35
TypeOrmModule . forRootAsync ( {
31
- imports : [ SettingModule ] ,
32
- inject : [ SettingService ] ,
33
- useFactory : ( settingService : SettingService ) =>
34
- settingService . typeOrmUseFactory ,
36
+ imports : [ ConfigModule ] ,
37
+ inject : [ ConfigService ] ,
38
+ useFactory : ( configService : ConfigService ) =>
39
+ configService . get ( typeormConfigKey ) ,
35
40
} ) ,
36
41
UserModule ,
37
42
AuthModule ,
0 commit comments