From 50b270db6fda60b5b3e39a9dbada5c27a14cbad1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 22 Feb 2023 19:38:55 -0800 Subject: fee slider wip --- src/components/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/index.js') diff --git a/src/components/index.js b/src/components/index.js index ab54e09f..0d1d8d1d 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,3 +1,4 @@ +export { default as Slider } from './Slider.svelte'; export { default as Pinpad } from './Pinpad.svelte'; export { default as Balance } from './Balance.svelte'; export { default as Lnurlp } from './Lnurlp.svelte'; -- cgit v1.2.3 From 34bc1c031378f8333819f2b46fb74f46634fb639 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 27 Feb 2023 19:28:09 -0800 Subject: api docs --- src/components/Code.svelte | 15 ++++++ src/components/index.js | 1 + src/lib/samples.js | 22 +++++++++ src/routes/(static)/+layout.server.js | 16 +++++++ src/routes/(static)/+layout.svelte | 6 ++- src/routes/(static)/docs/+page.server.js | 4 ++ src/routes/(static)/docs/+page.svelte | 81 +++++++++++++++++++++++++------- 7 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 src/components/Code.svelte create mode 100644 src/lib/samples.js create mode 100644 src/routes/(static)/+layout.server.js create mode 100644 src/routes/(static)/docs/+page.server.js (limited to 'src/components/index.js') diff --git a/src/components/Code.svelte b/src/components/Code.svelte new file mode 100644 index 00000000..b3181d0a --- /dev/null +++ b/src/components/Code.svelte @@ -0,0 +1,15 @@ + + +
+
{samples[sample]}
+ +
diff --git a/src/components/index.js b/src/components/index.js index 0d1d8d1d..1853e7c9 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,3 +1,4 @@ +export { default as Code } from './Code.svelte'; export { default as Slider } from './Slider.svelte'; export { default as Pinpad } from './Pinpad.svelte'; export { default as Balance } from './Balance.svelte'; diff --git a/src/lib/samples.js b/src/lib/samples.js new file mode 100644 index 00000000..4af61822 --- /dev/null +++ b/src/lib/samples.js @@ -0,0 +1,22 @@ +export default { + register: `curl -s "https://coinos.io/api/register" -H "application/json" -d '{ + "username": "adam", + "password": "hunter2" +}'`, + login: `curl -s "https://coinos.io/api/login" -H "application/json" -d '{ + "username": "adam", + "password": "hunter2" +}'`, + invoice: `curl -s "https://coinos.io/api/invoice" + -H "application/json" + -H "Authorization: Bearer $token" + -d '{ + "invoice": { + "amount": 1000, + "type": "lightning", + "webhook": "https://example.com/payment/received", + "secret": "hunter2" + }, +}'`, + fetchInvoice: `curl -s "https://coinos.io/api/invoice/bc1qmhfk9stzffhd9umzmld92vff7zg3mdlh7rvvaj" -H "application/json" }'` +}; diff --git a/src/routes/(static)/+layout.server.js b/src/routes/(static)/+layout.server.js new file mode 100644 index 00000000..2deeebc5 --- /dev/null +++ b/src/routes/(static)/+layout.server.js @@ -0,0 +1,16 @@ +import { get, post, auth, protectedRoutes } from '$lib/utils'; + +export async function load({ cookies, request, url, params }) { + let token = cookies.get('token'); + let rate, + rates = { USD: 1 }; + + let user; + if (token) { + try { + user = await get('/me', auth(cookies)); + } catch (e) {} + } + + return { user }; +} diff --git a/src/routes/(static)/+layout.svelte b/src/routes/(static)/+layout.svelte index 6e31f17e..3d596dff 100644 --- a/src/routes/(static)/+layout.svelte +++ b/src/routes/(static)/+layout.svelte @@ -1,8 +1,12 @@ - + +
diff --git a/src/routes/(static)/docs/+page.server.js b/src/routes/(static)/docs/+page.server.js new file mode 100644 index 00000000..e80365fa --- /dev/null +++ b/src/routes/(static)/docs/+page.server.js @@ -0,0 +1,4 @@ +export let load = async ({ cookies }) => { + let token = cookies.get('token'); + return { token }; +}; diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte index c634cd76..d44204d8 100644 --- a/src/routes/(static)/docs/+page.svelte +++ b/src/routes/(static)/docs/+page.svelte @@ -1,17 +1,67 @@ -Coming soon - - - - - - - - - - - - - + + +
+

API Documentation

+ +

+ Coinos has a simple REST API that can be used to register accounts, fetch data, and make + payments +

+ +

* = required parameter

+ +

Base URL

+
+
https://coinos.io/api
+
+
+ +

Auth Token

+

This JWT authorizes you to use the API

+
+
export token="{token}"
+
+
+ +

POST /register

+

Register a new user account with a username and password

+ + +

POST /login

+

Login to an account to get its auth token

+ + +

POST /invoice

+

Create an invoice.

+
+
+ type: bitcoin or lightning +
+
+ amount: integer satoshis (optional) +
+
+ webhook: a URL that we'll POST to when the invoice is + paid (optional) +
+
+ secret: a secret to send with the POST (optional) +
+
+ + + +

GET /invoice/:hash

+

+ Fetch an invoice by passing a bitcoin address or lightning payment hash +

+ +
+ @@ -73,5 +123,4 @@ Coming soon - - + -- cgit v1.2.3