waterwolf-auth/src/app.datasource.ts
Kakious a71c33c085 feat: implement base db support
feat: implement dev containers
2024-07-16 01:05:06 -04:00

22 lines
765 B
TypeScript

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,
});