import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { GraphQLModule } from '@nestjs/graphql'; import { TypeOrmModule } from '@nestjs/typeorm'; import { AppController } from './app.controller'; import { AppResolver } from './app.resolver'; import { AppService } from './app.service'; import configuration from './commons/config/configuration'; @Module({ imports: [ ConfigModule.forRoot({ load: [configuration], }), TypeOrmModule.forRootAsync({ imports: [ConfigModule], useFactory: (cnfigService: ConfigService) => ({ type: 'postgres', host: cnfigService.get('db.postgres.host'), port: cnfigService.get('db.postgres.port'), username: cnfigService.get('db.postgres.username'), password: cnfigService.get('db.postgres.password'), database: cnfigService.get('db.postgres.database'), synchronize: true, autoLoadEntities: true, }), inject: [ConfigService], }), GraphQLModule.forRootAsync({ imports: [ConfigModule], useFactory: (cnfigService: ConfigService) => ({ debug: cnfigService.get('env') !== 'prod', playground: true, autoSchemaFile: true, }), inject: [ConfigService], }), ], controllers: [AppController], providers: [AppService, AppResolver], }) export class AppModule {}