mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
Главный сервис, где выдается данные о курсе валюты
This commit is contained in:
parent
a2eccb53e9
commit
c5fa45c0fa
4 changed files with 694 additions and 0 deletions
23
server/main.js
Normal file
23
server/main.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const fastify = require('fastify')({logger: true})
|
||||
const rate = require('../database/main.js');
|
||||
|
||||
fastify.get('/api/getRate/', async function (req, res){
|
||||
const query = req.query;
|
||||
if (query['fromCurrency'] || query['convCurrency']) return;
|
||||
|
||||
if (query['date']) return rate.getDay(query['fromCurrency'], query['convCurrency'], query['date']);
|
||||
else if (query['startDate'] && query['endDate']) return rate.getPeriod(
|
||||
query['fromCurrency'],
|
||||
query['convCurrency'],
|
||||
query['startDate'],
|
||||
query['endDate']
|
||||
);
|
||||
else return;
|
||||
});
|
||||
|
||||
fastify.listen({ port: 3000 }, function (err) {
|
||||
if (err) {
|
||||
fastify.log.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue