Files
Online-Topup-V1/knexfile.js
T
2025-06-25 17:54:24 +07:00

113 lines
3.0 KiB
JavaScript

require('dotenv').config();
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: {
min: 2,
max: 100,
idleTimeoutMillis: 30000, // ← Contoh: 30 detik idle timeout
acquireTimeoutMillis: 20000, // Maksimal waktu tunggu koneksi dari pool
// maxLifetimeMillis: 300000 // maksimal umur koneksi: 5 menit (300.000 ms)
},
migrations: {
directory: './infrastructure/database/migrations',
},
},
testing: {
client: 'pg',
connection: process.env.DB_URL,
migrations: {
directory: './infrastructure/database/migrations',
},
seeds: { directory: './infrastructure/database/seeds' },
},
production: {
client: 'pg',
connection: {
host: host,
database: database,
user: user,
password: password,
},
// connection: process.env.DB_URL,
pool: {
min: 2,
max: 100,
idleTimeoutMillis: 30000, // ← Contoh: 30 detik idle timeout
acquireTimeoutMillis: 20000, // Maksimal waktu tunggu koneksi dari pool
// maxLifetimeMillis: 300000 // maksimal umur koneksi: 5 menit (300.000 ms)
},
migrations: {
directory: './infrastructure/database/migrations',
},
},
};