diff options
Diffstat (limited to 'src/routes/(app)/buy/+page.server.js')
| -rw-r--r-- | src/routes/(app)/buy/+page.server.js | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/routes/(app)/buy/+page.server.js b/src/routes/(app)/buy/+page.server.js index b97ac88b..b6604926 100644 --- a/src/routes/(app)/buy/+page.server.js +++ b/src/routes/(app)/buy/+page.server.js @@ -1,7 +1,7 @@ -import { env } from '$env/dynamic/private'; -import { error, fail, redirect } from '@sveltejs/kit'; -import { post, auth } from '$lib/utils'; -import { createTicket } from '$lib/ticket'; +import { env } from "$env/dynamic/private"; +import { error, fail, redirect } from "@sveltejs/kit"; +import { post, auth } from "$lib/utils"; +import { createTicket } from "$lib/ticket"; export let load = async ({ cookies }) => { let invoice = await post('/invoice', { invoice: { type: 'bitcoin' }}, auth(cookies)); @@ -10,24 +10,25 @@ export let load = async ({ cookies }) => { } export const actions = { - default: async ({ cookies, request }) => { - let form = await request.formData(); + default: async ({ cookies, request }) => { + let form = await request.formData(); - let amount = parseFloat(form.get('amount')); - if (!amount || amount < 0 || amount > 500) return fail(400, { message: 'Invalid amount' }); + let amount = parseFloat(form.get("amount")); + if (!amount || amount < 0 || amount > 500) + return fail(400, { message: "Invalid amount" }); - await post( - '/buy', - { - amount: form.get('amount'), - number: form.get('number').replace(/\s+/g, ''), - month: form.get('expiry').slice(0, 2), - year: form.get('expiry').slice(-2), - cvc: form.get('cvc') - }, - auth(cookies) - ); + await post( + "/buy", + { + amount: form.get("amount"), + number: form.get("number").replace(/\s+/g, ""), + month: form.get("expiry").slice(0, 2), + year: form.get("expiry").slice(-2), + cvc: form.get("cvc"), + }, + auth(cookies) + ); - throw redirect(307, `/${form.get('username')}/payments`); - } + throw redirect(307, `/${form.get("username")}/payments`); + }, }; |
