aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice/+server.js
blob: a4c4f9c800501d8fab4ff6b704c68c125d5cd7b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import { auth, get, post } from '$lib/utils';

export async function POST({ request }) {
	let network = 'lightning';
	let { amount, currency, rate, tip, text, username } = await request.json();

	({ text } = await post('/lightning/invoice', { amount }, auth(request)));
	let invoice = { amount, currency, network, rate, tip, text };
	let { uuid } = await post('/invoice', { invoice, user: { username } }, auth(request));

	return new Response(JSON.stringify(uuid), { headers: { 'content-type': 'application/json' } });
}