aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/Code.svelte22
-rw-r--r--src/lib/samples.js9
-rw-r--r--src/routes/(static)/docs/+page.svelte29
3 files changed, 44 insertions, 16 deletions
diff --git a/src/components/Code.svelte b/src/components/Code.svelte
index b3181d0a..0e09191e 100644
--- a/src/components/Code.svelte
+++ b/src/components/Code.svelte
@@ -5,11 +5,27 @@
export let sample;
</script>
-<div class="bg-black text-white rounded-lg p-4 flex gap-4 whitespace-pre-wrap font-mono">
- <div class="w-full break-all">{samples[sample]}</div>
+<div
+ class="bg-black text-white rounded-lg p-4 flex gap-4 whitespace-pre-wrap font-mono"
+>
+ <div class="overflow-x-scroll max-w-full scrollbar-hide">
+ <div class="break-all min-w-[800px]">{samples[sample]}</div>
+ </div>
<button
class="ml-auto my-auto invert opacity-90"
on:click={() => copy(samples[sample].replace(/^\s+/gm, '').replace(/\n/g, ''))}
- ><Icon icon="copy" style="w-8" /></button
+ ><Icon icon="copy" style="w-10 max-w-none" /></button
>
</div>
+
+<style>
+ .scrollbar-hide::-webkit-scrollbar {
+ display: none;
+ }
+
+ /* For IE, Edge and Firefox */
+ .scrollbar-hide {
+ -ms-overflow-style: none; /* IE and Edge */
+ scrollbar-width: none; /* Firefox */
+ }
+</style>
diff --git a/src/lib/samples.js b/src/lib/samples.js
index 4af61822..93b9aa24 100644
--- a/src/lib/samples.js
+++ b/src/lib/samples.js
@@ -1,13 +1,13 @@
export default {
- register: `curl -s "https://coinos.io/api/register" -H "application/json" -d '{
+ register: `curl "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 '{
+ login: `curl "https://coinos.io/api/login" -H "application/json" -d '{
"username": "adam",
"password": "hunter2"
}'`,
- invoice: `curl -s "https://coinos.io/api/invoice"
+ invoice: `curl "https://coinos.io/api/invoice"
-H "application/json"
-H "Authorization: Bearer $token"
-d '{
@@ -18,5 +18,6 @@ export default {
"secret": "hunter2"
},
}'`,
- fetchInvoice: `curl -s "https://coinos.io/api/invoice/bc1qmhfk9stzffhd9umzmld92vff7zg3mdlh7rvvaj" -H "application/json" }'`
+ fetchInvoice: `curl "https://coinos.io/api/invoice/bc1qmhfk9stzffhd9umzmld92vff7zg3mdlh7rvvaj"
+ -H "application/json"'`
};
diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte
index d44204d8..cb82bd05 100644
--- a/src/routes/(static)/docs/+page.svelte
+++ b/src/routes/(static)/docs/+page.svelte
@@ -1,10 +1,16 @@
<script>
+ import { copy } from '$lib/utils';
import { Code, Icon } from '$comp';
+ import { PUBLIC_COINOS_URL } from '$env/static/public';
export let data;
let { token } = data;
+ let api = PUBLIC_COINOS_URL + '/api';
+
+ if (!token) token = '<login to see your token here>';
+ let tokenSample = `export token="${token}"`;
</script>
-<div class="space-y-8 text-xl mt-20">
+<div class="space-y-8 lg:text-xl mt-20 w-full max-w-full">
<h1 class="text-4xl">API Documentation</h1>
<p class="text-secondary">
@@ -16,15 +22,19 @@
<h2 class="text-2xl">Base URL</h2>
<div class="bg-black text-white rounded-lg p-4 flex gap-4">
- <div>https://coinos.io/api</div>
- <div class="ml-auto my-auto invert opacity-90"><Icon icon="copy" style="w-8" /></div>
+ <div>{api}</div>
+ <button class="ml-auto my-auto invert opacity-90" on:click={() => copy(api)}
+ ><Icon icon="copy" style="w-10 max-w-none" /></button
+ >
</div>
<h2 class="text-2xl">Auth Token</h2>
<p class="text-secondary">This JWT authorizes you to use the API</p>
<div class="bg-black text-white rounded-lg p-4 flex gap-4">
- <div class="w-full break-all">export token="{token}"</div>
- <div class="ml-auto my-auto invert opacity-90"><Icon icon="copy" style="w-8" /></div>
+ <div class="w-full break-all">{tokenSample}</div>
+ <button class="ml-auto my-auto invert opacity-90" on:click={() => copy(tokenSample)}
+ ><Icon icon="copy" style="w-10 max-w-none" /></button
+ >
</div>
<h2 class="text-2xl">POST /register</h2>
@@ -42,17 +52,17 @@
<span class="font-mono font-bold">type</span>: bitcoin or lightning
</div>
<div class="text-secondary">
- <span class="font-mono font-bold">amount</span>: integer satoshis (optional)
+ <span class="font-mono font-bold">amount</span>: amount in satoshis
</div>
<div class="text-secondary">
- <span class="font-mono font-bold">webhook</span>: a URL that we'll POST to when the invoice is
- paid (optional)
+ <span class="font-mono font-bold">webhook</span>: an endpoint to hit when the invoice is paid
</div>
<div class="text-secondary">
- <span class="font-mono font-bold">secret</span>: a secret to send with the POST (optional)
+ <span class="font-mono font-bold">secret</span>: a secret string for the webhook to check
</div>
</div>
+ hey
<Code sample="invoice" />
<h2 class="text-2xl">GET /invoice/:hash</h2>
@@ -123,4 +133,5 @@
<!-- -->
<!-- curl -s "$api/bitcoin/send" -H "$json" -H "$auth" -d '{"address": "bc1qqc9azhdjjpdxenrndt8cw4tw9del5pyrjn0wln", "tx": { "hex": "'$hex'", "fee": "'$fee'" }}' | jq -r '{ amount, fee, balance: (.account.balance)}' -->
<!-- echo "" -->
+
<!-- `} -->