-
Notifications
You must be signed in to change notification settings - Fork 4
/
ormconfig.js
43 lines (39 loc) · 1013 Bytes
/
ormconfig.js
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
33
34
35
36
37
38
39
40
41
42
43
require('dotenv/config')
const {
NODE_ENV,
CLOUD_DATABASE_HOST,
CLOUD_DATABASE_PASSWORD,
CLOUD_DATABASE_USER,
LOCAL_DATABASE_HOST,
LOCAL_DATABASE_USER,
LOCAL_DATABASE_PASSWORD,
} = process.env
const database = {
development: 'main',
production: 'main',
test: 'test',
}
const config = {
type: 'postgres',
host: NODE_ENV === 'production' ? CLOUD_DATABASE_HOST : LOCAL_DATABASE_HOST,
port: 5432,
username:
NODE_ENV === 'production' ? CLOUD_DATABASE_USER : LOCAL_DATABASE_USER,
password:
NODE_ENV === 'production'
? CLOUD_DATABASE_PASSWORD
: LOCAL_DATABASE_PASSWORD,
database: database[process.env.NODE_ENV],
entities:
process.env.NODE_ENV === 'test'
? ['src/entities/*.ts']
: ['dist/entities/*.js', 'modules/**/entities/*.js'],
logging: process.env.NODE_ENV === 'development',
migrationsTableName: 'migration',
migrations: ['migration/*.js'],
synchronize: true,
cli: {
migrationsDir: 'migration',
},
}
module.exports = config