waterwolf-auth/src/app.datasource.ts

23 lines
765 B
TypeScript
Raw Normal View History

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<string>('DATABASE_HOST'),
port: configService.getOrThrow<number>('DATABASE_PORT'),
username: configService.getOrThrow<string>('DATABASE_USER'),
password: configService.getOrThrow<string>('DATABASE_PASSWORD', ''),
database: configService.getOrThrow<string>('DATABASE_NAME'),
charset: 'UTF8MB4',
entities: DATABASE_ENTITIES,
migrations: DATABASE_MIGRATION,
});