From 6d241ffd11fe061758cfc6d6741447022eb3203a Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 2 Aug 2024 15:40:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=83?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20?= =?UTF-8?q?=D1=81=D0=B1=D0=BE=D1=80=D0=BE=D0=BC=20=D0=B2=D0=B0=D0=BB=D1=8E?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collect-currency/main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 collect-currency/main.js diff --git a/collect-currency/main.js b/collect-currency/main.js new file mode 100644 index 0000000..8511969 --- /dev/null +++ b/collect-currency/main.js @@ -0,0 +1,19 @@ +const schedule = require('node-schedule'); +const config = require('../config/main.js')(); +const cron = require('cron-validator'); + +const save_fiat = require('./save_fiat'); +const save_crypto = require('./save_crypto'); + +async function main() { + const config_schedule = config['currency']['collecting']['schedule']; + if (!config_schedule) throw new Error('The crontab schedule is not set'); + if (!cron.isValidCron(config_schedule, {alias: true})) throw new Error('The crontab is invalid'); + + schedule.scheduleJob(config_schedule, async function () { + await save_fiat(); + await save_crypto(); + }); +} + +main(); \ No newline at end of file