remove-postpaid-product.js
847 Bytes
const MODULE_NAME = 'CONFIG.REMOVE-POSTPAID-PRODUCT';
const fs = require('fs/promises');
const logger = require('tektrans-logger');
const configData = require('./data');
/**
* Menghapus nilai terkini config.products (postpaid)
*
* @param {string} name
*
*/
module.exports = async (xid, name) => {
try {
logger.verbose(`${MODULE_NAME} B4361668: remove postpaid product from config file`, {
xid,
key: name,
});
const config = await configData.reload();
delete config.postpaid_products[name];
await fs.writeFile('config.json', JSON.stringify(config, null, 4));
await configData.reload();
} catch (e) {
logger.warn(`${MODULE_NAME} 9E5C6976: Exception`, {
xid,
eCode: e.code,
eMessage: e.message,
});
}
};