From 76a16fcb4de1ccb351fbc45e85ac174fc0718c25 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 14 Aug 2021 04:39:34 -0400 Subject: startup scripts --- index.js | 2 ++ startup.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 startup.js diff --git a/index.js b/index.js index 44f41103..5017720a 100644 --- a/index.js +++ b/index.js @@ -93,6 +93,8 @@ app.use("/referrals", referralsRouter); var adminRouter = require("./routes/admin.js"); app.use("/admin", adminAuth, adminRouter); +require("./startup"); + app.use((err, req, res, next) => { const details = { path: req.path, diff --git a/startup.js b/startup.js new file mode 100644 index 00000000..807604e8 --- /dev/null +++ b/startup.js @@ -0,0 +1,25 @@ +// Can use this file to run custom scripts on startup + +/* +(async () => { + let invoice = await db.Invoice.findOne({ + where: { id: 47391 } + }); + + let payment = await db.Payment.findOne({ + where: { invoice_id: 47391 }, + + include: { + model: db.Account, + as: "account" + } + }); + + console.log(invoice.id, payment.id); + try { + await callWebhook(invoice, payment); + } catch (e) { + console.log("uh oh", e); + } +})(); +*/ -- cgit v1.2.3 From d4bdd2e4bdfaeed38fb6007b337b32d494b3997c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 18 Aug 2021 15:44:24 -0400 Subject: check for lightning message --- lib/send.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/send.js b/lib/send.js index 92b2eda3..293473d9 100644 --- a/lib/send.js +++ b/lib/send.js @@ -59,6 +59,7 @@ send = async (amount, memo, hash, user) => { fee_limit: { fixed: Math.min(10000, account.balance) }, }); + if (!m) throw new Error("lightning payment failed"); if (m.payment_error) throw new Error(m.payment_error); ({ -- cgit v1.2.3