eslint фикс

This commit is contained in:
Данил 2024-08-14 21:20:08 +03:00
parent bfccc5aac2
commit d7bcaf8c2e
8 changed files with 24 additions and 24 deletions

View file

@ -2,7 +2,7 @@ const ChartJSImage = require('chart.js-image');
const pool = require('../shared/database/src/postgresql.js'); const pool = require('../shared/database/src/postgresql.js');
const fs = require('fs'); const fs = require('fs');
const axios = require('axios'); const axios = require('axios');
const logger = require('../shared/logger/src/main.js') const logger = require('../shared/logger/src/main.js');
/** /**
* Graph generation * Graph generation
@ -109,4 +109,4 @@ function save_chart(url, filename) {
); );
} }
module.exports = { gen_chart, save_chart } module.exports = { gen_chart, save_chart };

View file

@ -20,9 +20,9 @@ function main() {
fs.unlinkSync(`../charts/${files[i]}`); fs.unlinkSync(`../charts/${files[i]}`);
} }
} }
} catch { return } } catch { return; }
} }
}) });
} }
schedule.scheduleJob('9 20 * * *', async function () { schedule.scheduleJob('9 20 * * *', async function () {

View file

@ -41,7 +41,7 @@ function save_crypto() {
value, value,
pair, pair,
new Date(data['time']).toLocaleDateString() new Date(data['time']).toLocaleDateString()
]) ]);
if (db['rows'][0]) return; if (db['rows'][0]) return;
await pool.query(`INSERT INTO currency (from_currency, conv_currency, rate, date) await pool.query(`INSERT INTO currency (from_currency, conv_currency, rate, date)
@ -56,9 +56,9 @@ function save_crypto() {
}).catch((err) => { }).catch((err) => {
if (err.response?.data.detail) logger.error(err.response.data.detail); if (err.response?.data.detail) logger.error(err.response.data.detail);
if (err.response?.data.status === 429) { if (err.response?.data.status === 429) {
logger.info('CoinAPI rate limited, rotating token') logger.info('CoinAPI rate limited, rotating token');
rotate_key(coinapiKeys); rotate_key(coinapiKeys);
depth-- depth--;
save_crypto(); save_crypto();
} }
}); });
@ -73,7 +73,7 @@ function save_crypto() {
*/ */
function rotate_key(list) { function rotate_key(list) {
apiKeyIndex = list.indexOf(coinapiKeys[apiKeyIndex]) + 1 apiKeyIndex = list.indexOf(coinapiKeys[apiKeyIndex]) + 1;
} }
module.exports = save_crypto; module.exports = save_crypto;

View file

@ -41,7 +41,7 @@ async function save_fiat() {
new Date(data['timestamp']).toLocaleDateString() new Date(data['timestamp']).toLocaleDateString()
]); ]);
}).catch((err) => { }).catch((err) => {
logger.error(err) logger.error(err);
setTimeout(save_fiat, err.config.timeout); setTimeout(save_fiat, err.config.timeout);
}); });

View file

@ -21,7 +21,7 @@ fastify.get('/api/getRate/', async function (req, res){
return res.status(400).send({ return res.status(400).send({
status: 400, status: 400,
message: 'The from_currency and conv_currency fields are required' message: 'The from_currency and conv_currency fields are required'
}) });
} }
@ -58,13 +58,13 @@ fastify.get('/api/getChart/', async function (req, res){
query['conv_currency'], query['conv_currency'],
query['start_date'], query['start_date'],
query['end_date'], query['end_date'],
) );
if (config['currency']['chart']['save']) chart.save_chart( if (config['currency']['chart']['save']) chart.save_chart(
charts, charts,
`${query['from_currency']} ${query['conv_currency']} ` + `${query['from_currency']} ${query['conv_currency']} ` +
`(${query['start_date']} - ${query['end_date']}).png` `(${query['start_date']} - ${query['end_date']}).png`
) );
return res.status(200).send({ return res.status(200).send({
status: 200, status: 200,
@ -75,9 +75,9 @@ fastify.get('/api/getChart/', async function (req, res){
fastify.listen({ fastify.listen({
port: 3000, port: 3000,
host: config['server']['host'] ? config['server']['host'] : 'localhost', host: config['server']['host'] ? config['server']['host'] : 'localhost',
}, function (err) { }, (err) => {
if (err) { if (err) {
fastify.log.error(err) fastify.log.error(err);
process.exit(1) process.exit(1);
} }
}); });

View file

@ -5,7 +5,7 @@ const config = () => {
if (!fs.existsSync('../config.yaml')) return; if (!fs.existsSync('../config.yaml')) return;
return yaml.parse(fs.readFileSync('../config.yaml', 'utf-8')); return yaml.parse(fs.readFileSync('../config.yaml', 'utf-8'));
} };
module.exports = config; module.exports = config;

View file

@ -11,7 +11,7 @@ const logger = require('../../logger/src/main.js');
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');
const data = await pool.query('SELECT from_currency, conv_currency, date, rate FROM currency ' + const data = await pool.query('SELECT from_currency, conv_currency, date, rate FROM currency ' +
'WHERE from_currency = $1 AND conv_currency = $2 AND date = $3', [ 'WHERE from_currency = $1 AND conv_currency = $2 AND date = $3', [
@ -22,10 +22,10 @@ async function getDay(from_currency, conv_currency, date) {
if (!data) return new Error('Missing data'); if (!data) return new Error('Missing data');
let set_date = data['rows'][0]['date'] const set_date = data['rows'][0]['date'];
set_date = new Date(set_date.setDate(set_date.getDate() + 1)); data['rows'][0]['date'] = new Date(set_date.setDate(set_date.getDate() + 1));
logger.debug(data['rows'][0]) logger.debug(data['rows'][0]);
return data['rows'][0]; return data['rows'][0];
} }
@ -41,7 +41,7 @@ async function getDay(from_currency, conv_currency, date) {
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');
const data = await pool.query('SELECT * FROM currency WHERE ' + const data = await pool.query('SELECT * FROM currency WHERE ' +
'(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2 ORDER BY date', [ '(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2 ORDER BY date', [
@ -54,11 +54,11 @@ async function getPeriod(from_currency, conv_currency, start_date, end_date) {
if (!data) return new Error('Missing data'); if (!data) return new Error('Missing data');
for (let i = 0; i < data['rows'].length; i++) { for (let i = 0; i < data['rows'].length; i++) {
let date = data['rows'][i]['date'] let date = data['rows'][i]['date'];
date = new Date(date.setDate(date.getDate() + 1)); date = new Date(date.setDate(date.getDate() + 1));
} }
logger.debug(data['rows']) logger.debug(data['rows']);
return data['rows']; return data['rows'];
} }

View file

@ -18,7 +18,7 @@ function getCallerFile() {
callerFile = err.stack.shift().getFileName(); callerFile = err.stack.shift().getFileName();
if (currentFile !== callerFile) break; if (currentFile !== callerFile) break;
} }
} catch (e) {} } catch { return; }
Error.prepareStackTrace = originalFunc; Error.prepareStackTrace = originalFunc;