From 5d966f422a2977c87c657f88847932b0be943adc Mon Sep 17 00:00:00 2001 From: adb Date: Wed, 31 Mar 2021 21:42:23 +0200 Subject: [PATCH] add configProxy and update config.json --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1cbcd84..705936a 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,16 @@ import {DynDnsBot} from './DynDnsBot.js'; -import {loadData} from './jsonDataStore.js'; +import {loadData, storeData} from './jsonDataStore.js'; -let bot = new DynDnsBot({config: loadData('config.json')}); +let configPath = 'config.json'; +let config = loadData(configPath); + +let configProxy = new Proxy(config, { + set: (target, key, value) => { + console.log(`config changed: ${key} set from ${target[key]} to ${value}`); + target[key] = value; + storeData(config, configPath); + return true; + } +}); +let bot = new DynDnsBot({config: configProxy}); bot.setInterval(); \ No newline at end of file