aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice/index.js
blob: cf26b3c61848866247662f4c8807237089d9172f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { post } from '$lib/utils';

let network = 'lightning';

export async function POST({ request }) {
	let { amount, rate, username, text } = await request.json();
	if (!text) ({ text } = await post('/lightning/invoice', { amount }));
	let { uuid: id } = await post('/invoice', {
		invoice: { amount, currency: 'USD', network, rate, text },
		user: { username }
	});

	return { body: { id } };
}