Skip to content

Instantly share code, notes, and snippets.

@madebydin
Last active May 24, 2020 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madebydin/1f1f9aa97f96badbfbfb92fb327d2649 to your computer and use it in GitHub Desktop.
Save madebydin/1f1f9aa97f96badbfbfb92fb327d2649 to your computer and use it in GitHub Desktop.
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [
ConfigModule.forRoot(
{
envFilePath: '.env.dev',
isGlobal: true ,
}
),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
type: 'mysql',
host: configService.get<string>('DBHOST'),
port: configService.get<number>('DBPORT'),
username: configService.get<string>('DBUSER'),
password: configService.get<string>('DBPASS'),
database: configService.get<string>('DBNAME'),
entities: [__dirname + '/**/*.entity{.ts,.js}'],
synchronize: true,
}),
inject: [ConfigService],
})
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment