Files
Online-Topup-V1/infrastructure/transaction-time.js
T
Mohamad Ihsan 3902a74d6f Align transaction and log timestamps with Jakarta time
Keep recovered Load Balance writes and card audit atomic, and isolate Payment Recon tests.
2026-11-24 22:57:32 +07:00

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 };