import { ConfigService } from '@nestjs/config'; import { config } from 'dotenv'; import { DataSource } from 'typeorm'; import { DATABASE_MIGRATION } from './database/database.migration'; import { DATABASE_ENTITIES } from './database/database.entities'; config(); const configService = new ConfigService(); export default new DataSource({ type: 'mysql', host: configService.getOrThrow('DATABASE_HOST'), port: configService.getOrThrow('DATABASE_PORT'), username: configService.getOrThrow('DATABASE_USER'), password: configService.getOrThrow('DATABASE_PASSWORD', ''), database: configService.getOrThrow('DATABASE_NAME'), charset: 'UTF8MB4', entities: DATABASE_ENTITIES, migrations: DATABASE_MIGRATION, });