import { Module } from '@nestjs/common' import { ConfigModule, ConfigService } from '@nestjs/config' import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm' import { AppController } from './app.controller' import { AppService } from './app.service' import { PostsModule } from './posts/posts.module' import { Posts } from './posts/posts.entity' @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true }), TypeOrmModule.forRootAsync({ imports: [ConfigModule], inject: [ConfigService], useFactory: async (configService: ConfigService) => ({ type: configService.get('DATABASE_DIALECT'), host: configService.get('DATABASE_HOST'), port: configService.get('DATABASE_PORT'), username: configService.get('DATABASE_USERNAME'), password: configService.get('DATABASE_PASSWORD'), database: configService.get('DATABASE_NAME'), entities: [Posts], synchronize: true } as TypeOrmModuleOptions) }), PostsModule ], controllers: [AppController], providers: [AppService] }) export class AppModule {}