1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import cookie from 'cookie';
import { get, post } from '$lib/utils';
export async function POST({ request }) {
let { token } = cookie.parse(request.headers.get('cookie') || '');
let network = 'lightning';
let { amount, currency, rate, tip, text, username } = await request.json();
let headers = { authorization: `Bearer ${token}` };
({ text } = await post('/lightning/invoice', { amount }, headers));
let invoice = { amount, currency, network, rate, tip, text };
let { uuid } = await post('/invoice', { invoice, user: { username } }, headers);
return new Response(JSON.stringify(uuid), { headers: { 'content-type': 'application/json' } });
}
|