From e21330bee749de0ce6b3bec2dfc8385b64e90fdc Mon Sep 17 00:00:00 2001 From: Redume Date: Thu, 15 Feb 2024 22:19:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=80=D0=B5=D0=B3=D0=B2=D0=B5=D1=81=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B0=D0=BF=D0=B8=20=D0=B4=D0=B4=D0=B3=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=B0=D1=80=D0=BD=D0=BE=20=D0=BA=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=B6=D0=B4=D0=BE=D0=B9=20=D0=B2=D0=B0=D0=BB=D1=8E=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + utils/saveCourse.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 utils/saveCourse.js diff --git a/package.json b/package.json index 0983997..e2874da 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "author": "Redume", "license": "LGPL-3.0-only", "dependencies": { + "axios": "^1.6.7", "fastify": "^4.26.1", "pg": "^8.11.3", "yaml": "^2.3.4" diff --git a/utils/saveCourse.js b/utils/saveCourse.js new file mode 100644 index 0000000..20ea1b6 --- /dev/null +++ b/utils/saveCourse.js @@ -0,0 +1,22 @@ +const pool = require("../postgresql.js"); +const yaml = require("yaml") +const fs = require("fs"); +const axios = require("axios"); +const config = yaml.parse(fs.readFileSync("./config.yaml", "utf-8")); + +async function saveCourse() { + for (let i = 0; i < config['currency'].length; i++) { + for (let pair in config['currency'] ) { + const res = await axios.get( + `https://duckduckgo.com/js/spice/currency/1/${config['currency'][i]}/${config['currency'][pair]}` + ) + console.log(res.data) + + //TODO: добавить сохранение в бд + } + } + + +} + +module.exports = saveCourse; \ No newline at end of file