@@ -26,16 +26,29 @@ import { UserCredentialRepository } from './repositories/user-credential.reposit
2626import { IsUserAlreadyExistConstraint } from './dto/validators/is-user-already-exist-constraint' ;
2727import { AuthServiceFacade } from './services/facades/auth.service.facade' ;
2828import { CorsMiddleware } from './middlewares/cors/cors.middleware' ;
29- import { ConfigService } from './services/config.service' ;
29+ import { ConfigModule , ConfigService } from '@nestjs/config' ;
30+ import { CatalogModule } from './catalog/catalog.module' ;
31+ import { AuthModule } from './auth/auth.module' ;
32+ import databaseConfiguration from 'config/database/database.configuration' ;
33+ import thirdpartyConfiguration from 'config/thirdparty/thirdparty.configuration' ;
3034
3135@Module ( {
3236 imports : [
3337 HttpModule ,
34- TypeOrmModule . forRoot ( ) ,
38+ ConfigModule . forRoot ( {
39+ load : [ databaseConfiguration , thirdpartyConfiguration ] ,
40+ } ) ,
41+ TypeOrmModule . forRootAsync ( {
42+ imports : [ ConfigModule ] ,
43+ useFactory : ( config : ConfigService ) => config . get ( 'database' ) ,
44+ inject : [ ConfigService ] ,
45+ } ) ,
3546 TypeOrmModule . forFeature ( [ Label , Category , Item , Cart , CartDetail , User ] ) ,
3647 MulterModule . register ( {
3748 dest : './upload' ,
3849 } ) ,
50+ CatalogModule ,
51+ AuthModule ,
3952 ] ,
4053 controllers : [
4154 AppController ,
@@ -47,12 +60,6 @@ import { ConfigService } from './services/config.service';
4760 AuthController ,
4861 ] ,
4962 providers : [
50- {
51- provide : ConfigService ,
52- useValue : new ConfigService (
53- `${ process . env . NODE_ENV || 'development' } .env` ,
54- ) ,
55- } ,
5663 AppService ,
5764 { provide : 'CategoryRepository' , useClass : CategoryRepository } ,
5865 { provide : 'UserCredentialRepository' , useClass : UserCredentialRepository } ,
0 commit comments