aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice/+server.js
blob: 225f6bb18ba463a6b73ad180bdb77635c855409a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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' } });
}