-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathormconfig.js
37 lines (33 loc) · 1.16 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
26
27
28
29
30
31
32
33
34
35
36
37
const dotenv = require('dotenv');
const isDevEnv = (() => process.env.NODE_ENV === 'development')();
const getEnvVariables = {
host: isDevEnv ? process.env.DB_HOST_DEV : process.env.PROD_HOST_PROD,
username: isDevEnv ? process.env.DB_USERNAME_DEV : process.env.DB_USERNAME_PROD,
password: isDevEnv ? process.env.DB_PASSWORD_DEV : process.env.DB_PASSWORD_PROD,
databasename: isDevEnv ? process.env.DB_DATABASE_DEV : process.env.DB_DATABASE_PROD,
logging: isDevEnv ? true : false,
synchronize: isDevEnv ? true : false,
};
const entities = isDevEnv ? "src/db/entity/**/*.ts" : "build/db/entity/**/*.js";
module.exports = {
type: "postgres",
host: getEnvVariables.host,
port: 5432,
username: getEnvVariables.username,
password: getEnvVariables.password,
database: getEnvVariables.databasename,
synchronize: getEnvVariables.synchronize,
logging: getEnvVariables.logging,
entities: [entities],
migrations: [
"src/db/migration/**/*.ts"
],
subscribers: [
"src/db/subscriber/**/*.ts"
],
cli: {
entitiesDir: "src/db/entity",
migrationsDir: "src/db/migration",
subscribersDir: "src/db/subscriber"
}
}