mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
feat(server): Made a new Root with available currencies to collect and first and last collection date
This commit is contained in:
parent
fff7cebdb7
commit
9bc6c0a203
3 changed files with 31 additions and 0 deletions
11
nginx.conf
11
nginx.conf
|
@ -52,6 +52,17 @@ http {
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /api/metadata {
|
||||||
|
limit_req zone=kekkai burst=4;
|
||||||
|
|
||||||
|
add_header Access-Control-Allow-Origin *;
|
||||||
|
proxy_pass http://server_backend;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
location /api/getChart {
|
location /api/getChart {
|
||||||
limit_req zone=kekkai burst=4;
|
limit_req zone=kekkai burst=4;
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,11 @@ const fastify = require("fastify")({
|
||||||
|
|
||||||
const getRateRoute = require("./routes/getRate.js");
|
const getRateRoute = require("./routes/getRate.js");
|
||||||
const HomeRoute = require("./routes/home.js");
|
const HomeRoute = require("./routes/home.js");
|
||||||
|
const getMetadata = require("./routes/metadata.js");
|
||||||
|
|
||||||
fastify.register(getRateRoute);
|
fastify.register(getRateRoute);
|
||||||
fastify.register(HomeRoute);
|
fastify.register(HomeRoute);
|
||||||
|
fastify.register(getMetadata);
|
||||||
|
|
||||||
fastify.setNotFoundHandler(function (res, reply) {
|
fastify.setNotFoundHandler(function (res, reply) {
|
||||||
return reply.status(404).send({
|
return reply.status(404).send({
|
||||||
|
|
18
server/routes/metadata.js
Normal file
18
server/routes/metadata.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const pool = require('../../shared/database/src/postgresql.js');
|
||||||
|
const config = require('../../shared/config/src/main.js')();
|
||||||
|
|
||||||
|
module.exports = async function metadata(fastify) {
|
||||||
|
fastify.get('/api/metadata/', async function (req, res) {
|
||||||
|
const first_date = await pool.query('SELECT * FROM currency ORDER BY date LIMIT 1');
|
||||||
|
const last_date = await pool.query('SELECT * FROM currency ORDER BY date DESC LIMIT 1');
|
||||||
|
|
||||||
|
return res.status(200).send({
|
||||||
|
'first_date': first_date.rows[0]?.date ? first_date.rows[0]?.date : 'None',
|
||||||
|
'last_date': last_date.rows[0]?.date ? last_date.rows[0]?.date : 'None',
|
||||||
|
'currencies': {
|
||||||
|
'crypto': config['currency']['crypto'],
|
||||||
|
'fiat': config['currency']['fiat'],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue