diff options
| author | Adam Soltys <[email protected]> | 2025-02-07 22:23:00 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-07 22:23:00 -0800 |
| commit | 479cb9ad44d05b56cd2e60735687702fc37487a0 (patch) | |
| tree | fad9e4080887c2f11e8f750714c83e619f833afa /src/routes/(app)/apps/new/+page.server.ts | |
| parent | d92352dafc6d9e62716625d75be2316039a97a69 (diff) | |
| download | coinos-ui-479cb9ad44d05b56cd2e60735687702fc37487a0.tar.gz coinos-ui-479cb9ad44d05b56cd2e60735687702fc37487a0.zip | |
nwc connections
Diffstat (limited to 'src/routes/(app)/apps/new/+page.server.ts')
| -rw-r--r-- | src/routes/(app)/apps/new/+page.server.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/routes/(app)/apps/new/+page.server.ts b/src/routes/(app)/apps/new/+page.server.ts new file mode 100644 index 00000000..7c335f8c --- /dev/null +++ b/src/routes/(app)/apps/new/+page.server.ts @@ -0,0 +1,31 @@ +import getRates from "$lib/rates"; +import { auth, fd, post } from "$lib/utils"; +import { fail, redirect } from "@sveltejs/kit"; + +export const load = async ({ parent, url }) => { + const app = { + name: url.searchParams.get("name"), + pubkey: url.searchParams.get("pubkey"), + max_amount: url.searchParams.get("max_amount"), + budget_renewal: url.searchParams.get("budget_renewal"), + }; + + const { user } = await parent(); + const rates = await getRates(); + const rate = rates[user.currency]; + return { app, rate }; +}; + +export const actions = { + default: async ({ cookies, request }) => { + try { + const body = await fd(request); + await post("/app", body, auth(cookies)); + } catch (e) { + const { message: error } = e as Error; + return fail(400, { error }); + } + + redirect(307, "/settings/nostr"); + }, +}; |
