From 6f540461418e283f2c55478496aac403cfce72b8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 1 Nov 2022 11:51:14 -0700 Subject: parse end time --- routes/payments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/payments.js b/routes/payments.js index 4c71cde0..678b646c 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -112,7 +112,7 @@ app.get("/payments", auth, async (req, res) => { }; if (start) where.createdAt[Op.gte] = new Date(parseInt(start)); - if (end) where.createdAt[Op.lte] = new Date(end); + if (end) where.createdAt[Op.lte] = new Date(parseInt(end)); if (!req.user.account_id) return res.send([]); -- cgit v1.2.3 From 409aeb1d3de7bb7791725b9568986be5607a23f4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Nov 2022 15:56:44 -0700 Subject: increase max tip --- routes/invoices.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/routes/invoices.js b/routes/invoices.js index 3a7f16b5..16abab84 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -64,7 +64,7 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { let address, unconfidential, text; if (amount < 0) throw new Error("amount out of range"); - if (tip > amount || tip > 1000000 || tip < 0) + if (tip > 5 * amount || tip > 1000000 || tip < 0) throw new Error("tip amount out of range"); if (!user) ({ user } = req); @@ -82,8 +82,7 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { if (!user) throw new Error("user not provided"); if (!currency) currency = user.currency; if (!rate) rate = store.rates[currency]; - if (tip > amount || tip > 1000000) throw new Error("tip is too large"); - if (tip < 0 || amount < 0) throw new Error("invalid amount"); + if (amount < 0) throw new Error("invalid amount"); if (user.account.pubkey) { let { address, confidentialAddress } = await deriveAddress( -- cgit v1.2.3 From bf262fde314bd33f5040eccb5ac775ed92d6b766 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Nov 2022 16:18:14 -0700 Subject: locations endpoint --- index.js | 1 + routes/locations.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 routes/locations.js diff --git a/index.js b/index.js index c0db543c..0f0ad648 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ import "./lib/notifications"; import "./lib/mail"; import "./routes/assets"; +import "./routes/locations"; import "./routes/info"; import "./routes/users"; import "./routes/invoices"; diff --git a/routes/locations.js b/routes/locations.js new file mode 100644 index 00000000..3e0fee4c --- /dev/null +++ b/routes/locations.js @@ -0,0 +1,19 @@ +import app from "$app"; +import redis from "$lib/redis"; +import axios from "axios"; + +let locations; +app.get("/locations", async (req, res) => { + res.send({ locations }); +}); + +let getLocations = async () => { + let { data } = await axios.get('https://api.btcmap.org/v2/elements?updated_since=2022-09-19'); + locations = data.filter( + (l) => l['osm_json'].tags && l['osm_json'].tags['payment:coinos'] === 'yes' + ); + + setTimeout(getLocations, 60000); +} + +getLocations(); -- cgit v1.2.3