aboutsummaryrefslogtreecommitdiffstats
path: root/routes/invoices.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-01 11:07:37 -0800
committerAdam Soltys <[email protected]>2023-02-01 11:07:37 -0800
commit1ae65a5a143d218e21828e297fd7d0ba9ab372bf (patch)
tree6e425803038c575f87e14ae3392abae16d7ccf40 /routes/invoices.js
parent2eb199b8609b0976b4800815edcf73aa3da4b464 (diff)
downloadcoinos-server-1ae65a5a143d218e21828e297fd7d0ba9ab372bf.tar.gz
coinos-server-1ae65a5a143d218e21828e297fd7d0ba9ab372bf.zip
classic invoices
Diffstat (limited to 'routes/invoices.js')
-rw-r--r--routes/invoices.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/routes/invoices.js b/routes/invoices.js
index d1ec5338..2ca3b006 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -1,14 +1,38 @@
import { g, s } from "$lib/db";
import { generate } from "$lib/invoices";
+import got from "got";
+import config from "$config";
export default {
- async get({ query: { hash } }, res) {
+ async get({ params: { hash } }, res) {
let invoice = await g(`invoice:${hash}`);
- invoice.user = await g(`user:${invoice.uid}`);
+
+ if (invoice) {
+ invoice.user = await g(`user:${invoice.uid}`);
+ } else {
+ invoice = await got(`${config.classic}/invoice/${hash}`).json();
+ invoice.id = invoice.uuid;
+ invoice.classic = true;
+ invoice.user.username += "@classic";
+ }
+
res.send(invoice);
},
async create({ body: { invoice, user }, user: sender }, res) {
res.send(await generate({ invoice, user, sender }));
+ },
+
+ async classic({ params: { username } }, res) {
+ let invoice = await got
+ .post(`${config.classic}/invoice`, {
+ json: {
+ invoice: { amount: 0, network: "lightning" },
+ user: { username }
+ }
+ })
+ .json();
+
+ res.send(invoice);
}
};