From 059613490db9be904791686c49851ec1cc095774 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Jul 2022 21:06:01 -0700 Subject: register endpoint --- src/lib/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index 595d2dd8..b1bc24ec 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1,10 +1,14 @@ +import { browser } from "$app/env"; + export function scroll(section) { section.scrollIntoView({ behavior: 'smooth' }); } +const base = browser ? "" : import.meta.env.VITE_COINOS_URL; + export const post = (url, body) => - fetch(url, { + fetch(base + url, { method: 'POST', body: JSON.stringify(body), headers: { 'accept': 'application/json', 'content-type': 'application/json' } - }); + }).then(r => r.json); -- cgit v1.2.3 From aaa704f6cd760268ba5221c812b4f5a4df32bac3 Mon Sep 17 00:00:00 2001 From: secondl1ght <85003930+secondl1ght@users.noreply.github.com> Date: Wed, 27 Jul 2022 00:06:41 -0600 Subject: format --- src/lib/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index b1bc24ec..5b1bba7f 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1,14 +1,14 @@ -import { browser } from "$app/env"; +import { browser } from '$app/env'; export function scroll(section) { section.scrollIntoView({ behavior: 'smooth' }); } -const base = browser ? "" : import.meta.env.VITE_COINOS_URL; +const base = browser ? '' : import.meta.env.VITE_COINOS_URL; export const post = (url, body) => fetch(base + url, { method: 'POST', body: JSON.stringify(body), - headers: { 'accept': 'application/json', 'content-type': 'application/json' } - }).then(r => r.json); + headers: { accept: 'application/json', 'content-type': 'application/json' } + }).then((r) => r.json); -- cgit v1.2.3 From cd9e850f9e15e890727026942d646d59f526fe4e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Jul 2022 23:37:18 -0700 Subject: fix invoice endpoint --- src/lib/socket.js | 1 + src/lib/utils.js | 2 +- src/routes/invoice.js | 15 +++------------ 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/lib/socket.js b/src/lib/socket.js index 9d0c472e..90238c23 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -24,6 +24,7 @@ export const messages = (data) => ({ connected: auth, login() { + console.log("OY", data) user.set(data); } }); diff --git a/src/lib/utils.js b/src/lib/utils.js index 5b1bba7f..c17b0a98 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -11,4 +11,4 @@ export const post = (url, body) => method: 'POST', body: JSON.stringify(body), headers: { accept: 'application/json', 'content-type': 'application/json' } - }).then((r) => r.json); + }).then((r) => r.json()); diff --git a/src/routes/invoice.js b/src/routes/invoice.js index 147da2b7..4b3327f6 100644 --- a/src/routes/invoice.js +++ b/src/routes/invoice.js @@ -1,21 +1,12 @@ -import got from 'got'; +import { post } from '$lib/utils'; import { invoiceAmount } from '$lib/store'; const username = 'bob', network = 'lightning'; export async function GET({ params }) { - let text = await got - .post('http://localhost:3119/lightning/invoice', { - json: { amount: invoiceAmount } - }) - .text(); - - await got - .post('http://localhost:3119/invoice', { - json: { invoice: { text, network }, user: { username } } - }) - .json(); + let { text } = await post('/lightning/invoice', { amount: invoiceAmount }); + await post('/invoice', { invoice: { text, network }, user: { username } }); return { body: { text } }; } -- cgit v1.2.3 From 5bf4891768f1ee359ee5795272c289b40745aed5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 30 Jul 2022 11:13:39 -0700 Subject: get invoice by uuid --- src/components/AppHeader.svelte | 4 +- src/components/RegisterOrLogin.svelte | 2 +- src/lib/utils.js | 5 + src/routes/[username].js | 3 - src/routes/[username].svelte | 27 --- src/routes/[username]/index.js | 3 + src/routes/[username]/index.svelte | 27 +++ src/routes/[username]/receive.svelte | 188 ++++++++++++++++++++ src/routes/__layout.svelte | 2 +- src/routes/invoice/[amount].js | 12 -- src/routes/invoice/[amount].svelte | 322 ---------------------------------- src/routes/invoice/[id].js | 11 ++ src/routes/invoice/[id].svelte | 322 ++++++++++++++++++++++++++++++++++ src/routes/invoice/index.js | 11 ++ src/routes/receive.svelte | 178 ------------------- 15 files changed, 572 insertions(+), 545 deletions(-) delete mode 100644 src/routes/[username].js delete mode 100644 src/routes/[username].svelte create mode 100644 src/routes/[username]/index.js create mode 100644 src/routes/[username]/index.svelte create mode 100644 src/routes/[username]/receive.svelte delete mode 100644 src/routes/invoice/[amount].js delete mode 100644 src/routes/invoice/[amount].svelte create mode 100644 src/routes/invoice/[id].js create mode 100644 src/routes/invoice/[id].svelte create mode 100644 src/routes/invoice/index.js delete mode 100644 src/routes/receive.svelte (limited to 'src/lib/utils.js') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index b096f01e..99eea6d5 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -8,9 +8,11 @@