mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
Сделал управлением сбором валют
This commit is contained in:
parent
f1f990343a
commit
6d241ffd11
1 changed files with 19 additions and 0 deletions
19
collect-currency/main.js
Normal file
19
collect-currency/main.js
Normal file
|
@ -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();
|
Loading…
Add table
Reference in a new issue