forked from joaomoura/desafio-entrevista-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orm.config.ts
32 lines (27 loc) · 928 Bytes
/
orm.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import 'reflect-metadata';
import { DataSource, DataSourceOptions } from 'typeorm';
export const AppDataSourceConfig: DataSourceOptions = {
type: 'mysql',
host: process.env.DB_HOST || 'localhost',
port: 3306,
username: process.env.DB_USERNAME || 'root',
password: process.env.DB_PASSWORD || 'pass',
database: process.env.DB_NAME || 'development',
synchronize: true,
logging: false,
entities: [__dirname + '/src/**/*.entity{.ts,.js}'],
migrations: [__dirname + '/database/migration/*{.ts,.js}'],
subscribers: [],
};
export const TestDataSourceConfig: DataSourceOptions = {
type: 'sqlite',
database: ':memory:',
synchronize: true,
logging: false,
entities: [__dirname + '/src/**/*.entity{.ts,.js}'],
subscribers: [],
};
const config =
process.env.NODE_ENV === 'test' ? TestDataSourceConfig : AppDataSourceConfig;
export const AppDataSource = new DataSource(config);
export default config;