aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice/+server.js
blob: 24fffb21d29375085622363a7e9826f1ca3fc025 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { json as json$1 } from '@sveltejs/kit';
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 json$1({ id });
}