aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-05-13 02:24:05 -0400
committerAdam Soltys <[email protected]>2021-05-13 02:24:05 -0400
commit4d2379b801ed0a95e8538a64873a0be503e74672 (patch)
tree8114688e98443e0ab536e7367eecb2f5d40aafe0 /lib
parent7d6d6ca74f1f271427c271382fff49446aaa1895 (diff)
downloadcoinos-server-4d2379b801ed0a95e8538a64873a0be503e74672.tar.gz
coinos-server-4d2379b801ed0a95e8538a64873a0be503e74672.zip
confidential to non-confidential liquid conversion
Diffstat (limited to 'lib')
-rw-r--r--lib/rates.js10
-rw-r--r--lib/sockets.js3
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/rates.js b/lib/rates.js
index b9e889fb..80c22bf0 100644
--- a/lib/rates.js
+++ b/lib/rates.js
@@ -27,7 +27,9 @@ let fetchRates;
try {
let {
data: { rates: fx }
- } = await axios.get(`http://data.fixer.io/api/latest?access_key=${config.fixer}`);
+ } = await axios.get(
+ `http://data.fixer.io/api/latest?access_key=${config.fixer}`
+ );
let USD = fx["USD"];
Object.keys(fx).map(k => {
fx[k] = parseFloat((fx[k] / fx["USD"]).toFixed(6));
@@ -44,10 +46,12 @@ let fetchRates;
setTimeout(fetchRates, 7200000);
})();
-app.get('/rates',
+app.get(
+ "/rates",
ah(async (req, res, next) => {
res.send(app.get("rates"));
- }));
+ })
+);
setInterval(() => {
broadcast("rate", app.get("last"));
diff --git a/lib/sockets.js b/lib/sockets.js
index b6a806ff..931a9d23 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -92,10 +92,9 @@ wss.on("connection", function(ws, req) {
case "login":
let token = data;
- if (differenceInSeconds(new Date(), subSeconds(lastSeen[token], 5)) < 2) return;
+ if (differenceInSeconds(new Date(), lastSeen[token]) < 5) return;
lastSeen[token] = new Date();
-
try {
if (!token || token === "null") return ws.close();
const username = jwt.decode(token).username;