diff options
| author | secondl1ght <[email protected]> | 2022-08-24 18:47:21 -0400 |
|---|---|---|
| committer | secondl1ght <[email protected]> | 2022-08-24 18:47:21 -0400 |
| commit | 47d5d5bc6cdcd39f8d5ad93d9f5d15d3403c6c21 (patch) | |
| tree | da63f8ddb681f581f73e46b4fd39f4043c0d1f75 /src/routes/invoice/+server.js | |
| parent | 49925d3e67ad0d48dfdbcfe46d856cd98ed2161d (diff) | |
| parent | 68e34d886c26010dcc032ec9f71729070d767146 (diff) | |
| download | coinos-ui-47d5d5bc6cdcd39f8d5ad93d9f5d15d3403c6c21.tar.gz coinos-ui-47d5d5bc6cdcd39f8d5ad93d9f5d15d3403c6c21.zip | |
Merge branch 'master' of github.com:coinos/coinos-ui-v2
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' } }); } |
