mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
Сделал в некоторых местах JSDocs
This commit is contained in:
parent
d36f9a67f3
commit
74947f0409
4 changed files with 40 additions and 6 deletions
|
@ -5,10 +5,10 @@ const request = require('request');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Graph generation
|
* Graph generation
|
||||||
* @param from_currency {String} - The currency that is being converted
|
* @param {String} from_currency - The currency that is being converted
|
||||||
* @param conv_currency {String} - The currency to be converted into
|
* @param {String} conv_currency - The currency to be converted into
|
||||||
* @param start_date {String} - Start date of the period
|
* @param {String} start_date - Start date of the period
|
||||||
* @param end_date {String} - End date of the period
|
* @param {String} end_date - End date of the period
|
||||||
* @returns {Promise<Error|string>}
|
* @returns {Promise<Error|string>}
|
||||||
*/
|
*/
|
||||||
async function gen_chart(from_currency, conv_currency, start_date, end_date) {
|
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
|
* Saving a graph to a file
|
||||||
* @param url {String} - URL (or Buffer) to the chart
|
* @param {String} url - URL (or Buffer) to the chart
|
||||||
* @param filename {String} - filename
|
* @param {String} filename - filename
|
||||||
*/
|
*/
|
||||||
function save_chart(url, filename) {
|
function save_chart(url, filename) {
|
||||||
if (!fs.existsSync('../charts')) fs.mkdirSync('../charts');
|
if (!fs.existsSync('../charts')) fs.mkdirSync('../charts');
|
||||||
|
|
|
@ -2,6 +2,11 @@ const config = require('../config/main.js')();
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const pool = require('../database/postgresql.js');
|
const pool = require('../database/postgresql.js');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves exchange rate of the cryptocurrency
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
function save_fiat() {
|
function save_fiat() {
|
||||||
if (!config['currency']['collecting']['crypto']) return;
|
if (!config['currency']['collecting']['crypto']) return;
|
||||||
const depth = config['currency']['coinapiKeys']
|
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) {
|
function rotate_key(list, active) {
|
||||||
return active[0] = (active + 1) % list.length;
|
return active[0] = (active + 1) % list.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@ const pool = require('../database/postgresql.js');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const config = require('../config/main.js')();
|
const config = require('../config/main.js')();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves exchange rate of the fiat currency
|
||||||
|
* @returns {Object} -
|
||||||
|
*/
|
||||||
async function save_fiat() {
|
async function save_fiat() {
|
||||||
if (!config['currency']['collecting']['fiat']) return;
|
if (!config['currency']['collecting']['fiat']) return;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
const pool = require('./postgresql.js');
|
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) {
|
async function getDay(from_currency, conv_currency, date) {
|
||||||
if (!from_currency || !conv_currency) return new Error('fromCurrency and convCurrency are required');
|
if (!from_currency || !conv_currency) return new Error('fromCurrency and convCurrency are required');
|
||||||
else if (!date) return new Error('date is 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];
|
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) {
|
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');
|
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')
|
else if(!start_date || !end_date) return new Error('start_date and end_date are required')
|
||||||
|
|
Loading…
Add table
Reference in a new issue