aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice/+server.js
diff options
context:
space:
mode:
authorsecondl1ght <[email protected]>2022-08-24 18:47:21 -0400
committersecondl1ght <[email protected]>2022-08-24 18:47:21 -0400
commit8f8f85983d2f4cb734ed15b33ebc140028711733 (patch)
tree1bb87287c2dbeb681be1fb83971eea945fe19926 /src/routes/invoice/+server.js
parent80d2b8db2b85829ee539814c176ebcf354939ad6 (diff)
parente54f0cf98d65e71153c4613a1e9a9b845b9f8f87 (diff)
downloadcoinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.tar.gz
coinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.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.js24
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' } });
}