mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 11:06:28 +00:00
128 lines
3.2 KiB
JavaScript
128 lines
3.2 KiB
JavaScript
require('dotenv').config();
|
|
const { positiveIntegerFromEnv } = require('./infrastructure/runtime-config');
|
|
|
|
const poolOptions = {
|
|
min: 0,
|
|
idleTimeoutMillis: 30000,
|
|
acquireTimeoutMillis: positiveIntegerFromEnv('DB_POOL_ACQUIRE_TIMEOUT_MS', 5000),
|
|
};
|
|
|
|
const primaryPostgresPool = {
|
|
...poolOptions,
|
|
max: positiveIntegerFromEnv('DB_POOL_MAX', 8),
|
|
};
|
|
|
|
let host;
|
|
let database;
|
|
let port;
|
|
let user;
|
|
let password;
|
|
|
|
if (process.env.CUSTOM_MODE_NODE_ENV == 'devprod') {
|
|
// blok ini hanya digunakan untuk kebutuhan testing
|
|
if (process.env.SERVER_FOR == 'local') {
|
|
host = process.env.DB_HOST_LOCAL;
|
|
database = process.env.DB_NAME_LOCAL;
|
|
port = process.env.DB_PORT_LOCAL;
|
|
user = process.env.DB_USER_LOCAL;
|
|
password = process.env.DB_PASSWORD_LOCAL;
|
|
} else if (process.env.SERVER_FOR == 'development') {
|
|
host = '10.20.14.14';
|
|
database = 'postgres';
|
|
port = 5432;
|
|
user = 'postgres';
|
|
password = 'inhc0mmute_cms';
|
|
} else if (process.env.SERVER_FOR == 'production') {
|
|
host = '10.20.14.14';
|
|
database = 'postgres';
|
|
port = 5432;
|
|
user = 'postgres';
|
|
password = 'inhc0mmute_cms';
|
|
}
|
|
} else {
|
|
// setting an normal harusnya masuk blok ini
|
|
if (process.env.SERVER_FOR == 'local') {
|
|
host = process.env.DB_HOST_LOCAL;
|
|
database = process.env.DB_NAME_LOCAL;
|
|
port = process.env.DB_PORT_LOCAL;
|
|
user = process.env.DB_USER_LOCAL;
|
|
password = process.env.DB_PASSWORD_LOCAL;
|
|
} else if (process.env.SERVER_FOR == 'development') {
|
|
host = '10.20.14.14';
|
|
database = 'postgres';
|
|
port = 5432;
|
|
user = 'postgres';
|
|
password = 'inhc0mmute_cms';
|
|
} else if (process.env.SERVER_FOR == 'production') {
|
|
host = '10.1.201.75';
|
|
database = 'postgres';
|
|
port = 5432;
|
|
user = 'postgres';
|
|
password = 'inhc0mmute_cms';
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
// development: {
|
|
// client: "pg",
|
|
// connection: process.env.DB_URL,
|
|
// migrations: {
|
|
// directory: "./infrastructure/database/migrations",
|
|
// },
|
|
// seeds: { directory: "./infrastructure/database/seeds" },
|
|
// },
|
|
development: {
|
|
client: 'pg',
|
|
connection: {
|
|
host: host,
|
|
database: database,
|
|
user: user,
|
|
password: password,
|
|
},
|
|
// connection: process.env.DB_URL,
|
|
pool: primaryPostgresPool,
|
|
migrations: {
|
|
directory: './infrastructure/database/migrations',
|
|
},
|
|
},
|
|
|
|
testing: {
|
|
client: 'pg',
|
|
connection: process.env.DB_URL,
|
|
pool: primaryPostgresPool,
|
|
migrations: {
|
|
directory: './infrastructure/database/migrations',
|
|
},
|
|
seeds: { directory: './infrastructure/database/seeds' },
|
|
},
|
|
|
|
pooling: {
|
|
client: 'pg',
|
|
connection: {
|
|
host: process.env.DB_HOST_POOLING,
|
|
user: process.env.DB_USER_POOLING,
|
|
password: process.env.DB_PASSWORD_POOLING,
|
|
database: process.env.DB_NAME_POOLING,
|
|
},
|
|
pool: {
|
|
...poolOptions,
|
|
max: positiveIntegerFromEnv('DB_POOLING_POOL_MAX', 2),
|
|
},
|
|
},
|
|
|
|
production: {
|
|
client: 'pg',
|
|
connection: {
|
|
host: host,
|
|
database: database,
|
|
user: user,
|
|
password: password,
|
|
},
|
|
// connection: process.env.DB_URL,
|
|
pool: primaryPostgresPool,
|
|
migrations: {
|
|
directory: './infrastructure/database/migrations',
|
|
},
|
|
},
|
|
};
|