aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/qr
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-03 15:57:40 -0800
committerAdam Soltys <[email protected]>2024-12-03 16:46:25 -0800
commit7801ce67ace77f5de98ddc38d7b0b45c68faeb6b (patch)
tree64e3d8db8173db04e2181c3ddb33ef1a2406f301 /src/routes/(app)/qr
parent2b174ad557e82731e59ff47e705af085071f7132 (diff)
downloadcoinos-ui-7801ce67ace77f5de98ddc38d7b0b45c68faeb6b.tar.gz
coinos-ui-7801ce67ace77f5de98ddc38d7b0b45c68faeb6b.zip
cache qrs
Diffstat (limited to 'src/routes/(app)/qr')
-rw-r--r--src/routes/(app)/qr/[text]/+page.server.ts7
-rw-r--r--src/routes/(app)/qr/[text]/+page.svelte4
-rw-r--r--src/routes/(app)/qr/[text]/raw/+server.ts16
3 files changed, 19 insertions, 8 deletions
diff --git a/src/routes/(app)/qr/[text]/+page.server.ts b/src/routes/(app)/qr/[text]/+page.server.ts
index 09e7593f..5a9debb3 100644
--- a/src/routes/(app)/qr/[text]/+page.server.ts
+++ b/src/routes/(app)/qr/[text]/+page.server.ts
@@ -1,8 +1,3 @@
-import Qr from "qrcode-base64";
-
export async function load({ params }) {
- const { text } = params;
- const src = Qr.drawImg(text, { size: 600 });
-
- return { src, text };
+ return params;
}
diff --git a/src/routes/(app)/qr/[text]/+page.svelte b/src/routes/(app)/qr/[text]/+page.svelte
index 02a5b718..46420743 100644
--- a/src/routes/(app)/qr/[text]/+page.svelte
+++ b/src/routes/(app)/qr/[text]/+page.svelte
@@ -3,11 +3,11 @@
import Qr from "$comp/Qr.svelte";
import { back, copy } from "$lib/utils";
let { data } = $props();
- let { src, text } = data;
+ let { text } = data;
</script>
<div class="container px-4 max-w-4xl mx-auto space-y-5">
- <Qr {src} />
+ <Qr {text} />
<button
type="button"
diff --git a/src/routes/(app)/qr/[text]/raw/+server.ts b/src/routes/(app)/qr/[text]/raw/+server.ts
new file mode 100644
index 00000000..a24d3a3c
--- /dev/null
+++ b/src/routes/(app)/qr/[text]/raw/+server.ts
@@ -0,0 +1,16 @@
+import Qr from "qrcode-base64";
+
+export async function GET({ params }) {
+ const { text } = params;
+
+ const dataUri = Qr.drawImg(text, { size: 600 });
+ const base64Data = dataUri.split(",")[1];
+ const binaryData = Buffer.from(base64Data, "base64");
+
+ return new Response(binaryData, {
+ headers: {
+ "Content-Type": "image/gif",
+ "Cache-Control": "public, max-age=31536000, immutable",
+ },
+ });
+}