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