23 lines
680 B
TypeScript
23 lines
680 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { SequelizeModule } from '@nestjs/sequelize';
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
|
@Module({
|
|
imports: [
|
|
SequelizeModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
dialect: 'mysql',
|
|
host: configService.get('DB_HOST'),
|
|
port: configService.get<number>('DB_PORT'),
|
|
username: configService.get('DB_USERNAME'),
|
|
password: configService.get('DB_PASSWORD'),
|
|
database: configService.get('DB_DATABASE'),
|
|
autoLoadModels: true,
|
|
synchronize: true,
|
|
}),
|
|
}),
|
|
],
|
|
})
|
|
export class DatabaseModule { }
|