-
Notifications
You must be signed in to change notification settings - Fork 25
/
ormconfig.js
25 lines (22 loc) · 1.03 KB
/
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
const path = require('path')
const pathEntitiesDir = !['production', 'staging'].includes(process.env.NODE_ENV) ? 'src/entities/*.ts' : 'dist/entities/*.js'
const pathMigrationDir = !['production', 'staging'].includes(process.env.NODE_ENV) ? 'src/databases/migrations' : 'dist/databases/migrations'
const entitiesDir = path.resolve(process.cwd(), pathEntitiesDir)
const migrationsDir = path.resolve(process.cwd(), pathMigrationDir)
module.exports = {
type: 'postgres',
host: process.env.DB_HOST,
port: parseInt(process.env.DB_PORT),
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
entities: [entitiesDir],
migrations: [migrationsDir],
synchronize: !['production', 'staging'].includes(process.env.NODE_ENV) ? true : false,
logger: !['production', 'staging'].includes(process.env.NODE_ENV) ? 'advanced-console' : undefined,
logging: !['production', 'staging'].includes(process.env.NODE_ENV) ? true : false,
cli: {
entitiesDir: entitiesDir,
migrationsDir: migrationsDir
}
}