blob: d856ef6b964c09d7fcc1e470d14c8041141ce89e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { g, s } from "$lib/db";
import { generate } from "$lib/invoices";
import got from "got";
import config from "$config";
export default {
async get({ params: { hash } }, res) {
let invoice = await g(`invoice:${hash}`);
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.id = invoice.user.uuid;
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);
}
};
|