aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rates.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
committerAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
commit53aecbf35d056fc4d70ef1ab12d3634b265f2c0b (patch)
tree5caa996fc2eca705fb793e79d63bfbf5f9f93e48 /src/lib/rates.ts
parent9c7ade85841e4e608fd9d8468d19b42b79cd9868 (diff)
downloadcoinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.tar.gz
coinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.zip
cached rates
Diffstat (limited to 'src/lib/rates.ts')
-rw-r--r--src/lib/rates.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/rates.ts b/src/lib/rates.ts
new file mode 100644
index 00000000..96aaeac2
--- /dev/null
+++ b/src/lib/rates.ts
@@ -0,0 +1,13 @@
+import { get } from "$lib/utils";
+
+let last;
+let rates;
+
+export default async function getRates() {
+ if (!rates || Date.now() - last > 60000) {
+ rates = await get("/rates");
+ last = Date.now();
+ }
+
+ return rates;
+}