diff options
Diffstat (limited to 'src/routes/invoice/+server.js')
| -rw-r--r-- | src/routes/invoice/+server.js | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/routes/invoice/+server.js b/src/routes/invoice/+server.js index 3942904b..a4c4f9c8 100644 --- a/src/routes/invoice/+server.js +++ b/src/routes/invoice/+server.js @@ -1,16 +1,12 @@ -import cookie from 'cookie'; -import { get, post } from '$lib/utils'; +import { auth, 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)); + ({ text } = await post('/lightning/invoice', { amount }, auth(request))); let invoice = { amount, currency, network, rate, tip, text }; - let { uuid } = await post('/invoice', { invoice, user: { username } }, headers); + let { uuid } = await post('/invoice', { invoice, user: { username } }, auth(request)); return new Response(JSON.stringify(uuid), { headers: { 'content-type': 'application/json' } }); } |
