diff --git a/chart/main.js b/chart/main.js index ad8057c..9a76407 100644 --- a/chart/main.js +++ b/chart/main.js @@ -5,10 +5,10 @@ const request = require('request'); /** * Graph generation - * @param from_currency {String} - The currency that is being converted - * @param conv_currency {String} - The currency to be converted into - * @param start_date {String} - Start date of the period - * @param end_date {String} - End date of the period + * @param {String} from_currency - The currency that is being converted + * @param {String} conv_currency - The currency to be converted into + * @param {String} start_date - Start date of the period + * @param {String} end_date - End date of the period * @returns {Promise} */ async function gen_chart(from_currency, conv_currency, start_date, end_date) { @@ -77,8 +77,8 @@ async function gen_chart(from_currency, conv_currency, start_date, end_date) { /** * Saving a graph to a file - * @param url {String} - URL (or Buffer) to the chart - * @param filename {String} - filename + * @param {String} url - URL (or Buffer) to the chart + * @param {String} filename - filename */ function save_chart(url, filename) { if (!fs.existsSync('../charts')) fs.mkdirSync('../charts'); diff --git a/collect-currency/save_crypto.js b/collect-currency/save_crypto.js index 3d78fbe..d2d6988 100644 --- a/collect-currency/save_crypto.js +++ b/collect-currency/save_crypto.js @@ -2,6 +2,11 @@ const config = require('../config/main.js')(); const axios = require('axios'); const pool = require('../database/postgresql.js'); + +/** + * Saves exchange rate of the cryptocurrency + * @return {Object} + */ function save_fiat() { if (!config['currency']['collecting']['crypto']) return; const depth = config['currency']['coinapiKeys'] @@ -47,6 +52,13 @@ function save_fiat() { ); } +/** + * Changing API keys + * @param {Array} list - List of all keys + * @param active - Active API key + * @returns {number} - Outputs the number of the key that should work + */ + function rotate_key(list, active) { return active[0] = (active + 1) % list.length; } diff --git a/collect-currency/save_fiat.js b/collect-currency/save_fiat.js index bf27595..112edc8 100644 --- a/collect-currency/save_fiat.js +++ b/collect-currency/save_fiat.js @@ -2,6 +2,10 @@ const pool = require('../database/postgresql.js'); const axios = require('axios'); const config = require('../config/main.js')(); +/** + * Saves exchange rate of the fiat currency + * @returns {Object} - + */ async function save_fiat() { if (!config['currency']['collecting']['fiat']) return; diff --git a/database/main.js b/database/main.js index 089ec87..fe59025 100644 --- a/database/main.js +++ b/database/main.js @@ -1,5 +1,14 @@ const pool = require('./postgresql.js'); + +/** + * Getting the currency exchange rate for a specific day + * @param from_currency {String} + * @param conv_currency {String} + * @param date + * @returns {Promise<*|Error>} + */ + async function getDay(from_currency, conv_currency, date) { if (!from_currency || !conv_currency) return new Error('fromCurrency and convCurrency are required'); else if (!date) return new Error('date is required') @@ -16,6 +25,15 @@ async function getDay(from_currency, conv_currency, date) { return data['rows'][0]; } +/** + * Getting the exchange rate for a certain period + * @param {String} from_currency - The currency that is being converted + * @param {String} conv_currency - The currency to be converted into + * @param {String} start_date - Start date of the period + * @param {String} end_date - End date of the period + * @returns {Promise<*|Error>} + */ + async function getPeriod(from_currency, conv_currency, start_date, end_date) { if (!from_currency || !conv_currency) return new Error('from_currency and conv_currency are required'); else if(!start_date || !end_date) return new Error('start_date and end_date are required')