chore: The service name is passed together with the function
This commit is contained in:
parent
c7e955a9b6
commit
9d85aba937
1 changed files with 5 additions and 1 deletions
|
@ -3,12 +3,16 @@ const config = require('../utils/load_config.js')();
|
||||||
const { truncate_number } = require('../utils/truncate_number.js');
|
const { truncate_number } = require('../utils/truncate_number.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
info: {
|
||||||
|
name: 'CoinMarketCap',
|
||||||
|
},
|
||||||
parseCurrencies: async () => {
|
parseCurrencies: async () => {
|
||||||
const promises = config['currency']['crypto'].map(fromCurrency => {
|
const promises = config['currency']['crypto'].map(fromCurrency => {
|
||||||
return config['currency']['crypto'].map(convCurrency => {
|
return config['currency']['crypto'].map(convCurrency => {
|
||||||
if (fromCurrency === convCurrency) return Promise.resolve(null);
|
if (fromCurrency === convCurrency) return Promise.resolve(null);
|
||||||
|
|
||||||
const coinmarketcap = config['currency']['services']['coinmarketcap'];
|
const coinmarketcap = config['currency']['services']['coinmarketcap'];
|
||||||
|
const serviceName = module.exports.info.name;
|
||||||
|
|
||||||
return axios.get(
|
return axios.get(
|
||||||
coinmarketcap['base_url'],
|
coinmarketcap['base_url'],
|
||||||
|
@ -27,7 +31,7 @@ module.exports = {
|
||||||
const truncatedPriceStr = truncate_number(data.price, 3);
|
const truncatedPriceStr = truncate_number(data.price, 3);
|
||||||
const rate = parseFloat(truncatedPriceStr);
|
const rate = parseFloat(truncatedPriceStr);
|
||||||
|
|
||||||
console.log(`Data fetched from CoinMarketCap: ${fromCurrency} -> ${convCurrency}, Rate: ${rate}`);
|
console.log(`Data fetched from ${serviceName}: ${fromCurrency} -> ${convCurrency}, Rate: ${rate}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from_currency: fromCurrency,
|
from_currency: fromCurrency,
|
||||||
|
|
Loading…
Add table
Reference in a new issue