mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 11:06:28 +00:00
3902a74d6f
Keep recovered Load Balance writes and card audit atomic, and isolate Payment Recon tests.
29 lines
772 B
JavaScript
29 lines
772 B
JavaScript
const TRANSACTION_TIME_ZONE = 'Asia/Jakarta';
|
|
|
|
// Samakan jam bisnis aplikasi dengan sesi PostgreSQL.
|
|
function configureTransactionClock() {
|
|
process.env.TZ = TRANSACTION_TIME_ZONE;
|
|
}
|
|
|
|
function withTransactionTimeZone(config) {
|
|
const afterCreate = config.pool?.afterCreate;
|
|
|
|
return {
|
|
...config,
|
|
pool: {
|
|
...config.pool,
|
|
afterCreate(connection, done) {
|
|
function setTimeZone(error) {
|
|
if (error) return done(error, connection);
|
|
connection.query("SET TIME ZONE 'Asia/Jakarta'", (queryError) => done(queryError, connection));
|
|
}
|
|
|
|
if (afterCreate) afterCreate(connection, setTimeZone);
|
|
else setTimeZone();
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = { configureTransactionClock, withTransactionTimeZone };
|