diff options
| author | Adam Soltys <[email protected]> | 2022-08-23 02:26:09 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-23 02:26:14 -0700 |
| commit | 1072c7a213baeace777d18b888eb43086afeb87e (patch) | |
| tree | 57976cb64ee33680b03613a7c33b590fb1149d78 /src/routes/invoice/+server.js | |
| parent | eeb4f8e9c4e909da916aeae6adb9699aaa765604 (diff) | |
| download | coinos-ui-1072c7a213baeace777d18b888eb43086afeb87e.tar.gz coinos-ui-1072c7a213baeace777d18b888eb43086afeb87e.zip | |
generate new invoice on tip
Diffstat (limited to 'src/routes/invoice/+server.js')
| -rw-r--r-- | src/routes/invoice/+server.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/routes/invoice/+server.js b/src/routes/invoice/+server.js index c77784d7..4b961be9 100644 --- a/src/routes/invoice/+server.js +++ b/src/routes/invoice/+server.js @@ -1,16 +1,16 @@ -import { json as json$1 } from '@sveltejs/kit'; -import { post } from '$lib/utils'; -import { user } from '$lib/store'; - -let network = 'lightning'; +import cookie from 'cookie'; +import { get, post } from '$lib/utils'; 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: user.currency, network, rate, text }, - user: { username } - }); + 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 json$1({ id }); + return new Response(JSON.stringify(uuid), { headers: { 'content-type': 'application/json' } }); } |
