diff options
| author | Adam Soltys <[email protected]> | 2022-08-29 14:27:33 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-29 14:27:33 -0700 |
| commit | 68d41ff2329f32edbb927e322350983208cd99f9 (patch) | |
| tree | 0bfa6cf04a7590a53bad538ea466d8655b6b28fd | |
| parent | 506627db3b5b0f7e0558db1ff4fc3c7580580cb9 (diff) | |
| download | coinos-server-68d41ff2329f32edbb927e322350983208cd99f9.tar.gz coinos-server-68d41ff2329f32edbb927e322350983208cd99f9.zip | |
prettier
| -rw-r--r-- | routes/invoices.js | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/routes/invoices.js b/routes/invoices.js index 02a8308d..a86b5580 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -12,8 +12,8 @@ app.get( include: { model: db.User, as: "user", - attributes: ['username', 'currency'] - } + attributes: ["username", "currency"] + } }); res.send(invoice); @@ -32,7 +32,11 @@ app.post( let { blindkey } = invoice; if (invoice.amount < 0) throw new Error("amount out of range"); - if (invoice.tip > invoice.amount || invoice.tip > 1000000 || invoice.tip < 0) + if ( + invoice.tip > invoice.amount || + invoice.tip > 1000000 || + invoice.tip < 0 + ) throw new Error("tip amount out of range"); if (liquidAddress) { @@ -51,8 +55,10 @@ app.post( if (!user) throw new Error("user not provided"); if (!invoice.currency) invoice.currency = user.currency; if (!invoice.rate) invoice.rate = app.get("rates")[invoice.currency]; - if (invoice.tip > invoice.amount || invoice.tip > 1000000) throw new Error("tip is too large"); - if (invoice.tip < 0 || invoice.amount < 0) throw new Error("invalid amount"); + if (invoice.tip > invoice.amount || invoice.tip > 1000000) + throw new Error("tip is too large"); + if (invoice.tip < 0 || invoice.amount < 0) + throw new Error("invalid amount"); invoice.user_id = user.id; invoice.account_id = user.account_id; @@ -63,7 +69,8 @@ app.post( invoice.amount, invoice.tip, invoice.currency, - invoice.text && `${invoice.text.substr(0, 8)}..${invoice.text.substr(-6)}`, + invoice.text && + `${invoice.text.substr(0, 8)}..${invoice.text.substr(-6)}` ); if (!invoice.tip) invoice.tip = 0; @@ -96,3 +103,11 @@ app.post( } }) ); + +app.post( + "/:username/:network/invoice", + optionalAuth, + ah(async (req, res, next) => { + let { network, username } = req.params; + }) +); |
