serve a static website from your pds

Try to deploy

+11
package-lock.json
··· 15 }, 16 "devDependencies": { 17 "@sveltejs/adapter-auto": "^6.1.0", 18 "@sveltejs/kit": "^2.43.2", 19 "@sveltejs/vite-plugin-svelte": "^6.2.0", 20 "prettier": "^3.6.2", ··· 957 "version": "6.1.1", 958 "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-6.1.1.tgz", 959 "integrity": "sha512-cBNt4jgH4KuaNO5gRSB2CZKkGtz+OCZ8lPjRQGjhvVUD4akotnj2weUia6imLl2v07K3IgsQRyM36909miSwoQ==", 960 "dev": true, 961 "license": "MIT", 962 "peerDependencies": {
··· 15 }, 16 "devDependencies": { 17 "@sveltejs/adapter-auto": "^6.1.0", 18 + "@sveltejs/adapter-static": "^3.0.10", 19 "@sveltejs/kit": "^2.43.2", 20 "@sveltejs/vite-plugin-svelte": "^6.2.0", 21 "prettier": "^3.6.2", ··· 958 "version": "6.1.1", 959 "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-6.1.1.tgz", 960 "integrity": "sha512-cBNt4jgH4KuaNO5gRSB2CZKkGtz+OCZ8lPjRQGjhvVUD4akotnj2weUia6imLl2v07K3IgsQRyM36909miSwoQ==", 961 + "dev": true, 962 + "license": "MIT", 963 + "peerDependencies": { 964 + "@sveltejs/kit": "^2.0.0" 965 + } 966 + }, 967 + "node_modules/@sveltejs/adapter-static": { 968 + "version": "3.0.10", 969 + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.10.tgz", 970 + "integrity": "sha512-7D9lYFWJmB7zxZyTE/qxjksvMqzMuYrrsyh1f4AlZqeZeACPRySjbC3aFiY55wb1tWUaKOQG9PVbm74JcN2Iew==", 971 "dev": true, 972 "license": "MIT", 973 "peerDependencies": {
+1
package.json
··· 15 }, 16 "devDependencies": { 17 "@sveltejs/adapter-auto": "^6.1.0", 18 "@sveltejs/kit": "^2.43.2", 19 "@sveltejs/vite-plugin-svelte": "^6.2.0", 20 "prettier": "^3.6.2",
··· 15 }, 16 "devDependencies": { 17 "@sveltejs/adapter-auto": "^6.1.0", 18 + "@sveltejs/adapter-static": "^3.0.10", 19 "@sveltejs/kit": "^2.43.2", 20 "@sveltejs/vite-plugin-svelte": "^6.2.0", 21 "prettier": "^3.6.2",
+1 -1
proxy.js
··· 11 }); 12 13 const did = values.did, 14 - collection = "com.jakelazaroff.test", 15 rkey = values.rkey; 16 17 if (!did) {
··· 11 }); 12 13 const did = values.did, 14 + collection = "com.jakelazaroff.athost", 15 rkey = values.rkey; 16 17 if (!did) {
+9 -5
src/lib/atproto.ts
··· 33 34 async listBundles() { 35 const { data } = await this.#client.get("com.atproto.repo.listRecords", { 36 - params: { repo: this.#did, collection: "com.jakelazaroff.test" }, 37 }); 38 39 if (isXRPCErrorPayload(data)) throw new Error("couldn't load records"); ··· 47 }; 48 49 const { data } = await this.#client.post("com.atproto.repo.createRecord", { 50 - input: { repo: this.#did, collection: "com.jakelazaroff.test", rkey, record }, 51 }); 52 53 if (isXRPCErrorPayload(data)) throw new Error(data.error); ··· 55 56 async getBundle(rkey: string) { 57 const { data } = await this.#client.get("com.atproto.repo.getRecord", { 58 - params: { repo: this.#did, collection: "com.jakelazaroff.test", rkey }, 59 }); 60 61 if (isXRPCErrorPayload(data)) throw new Error("couldn't load records"); ··· 64 65 async uploadFiles(files: File[]) { 66 const assets: Bundle["assets"] = {}; 67 for (const file of files) { 68 if (!(file instanceof File)) continue; 69 70 const { data } = await this.#client.post("com.atproto.repo.uploadBlob", { input: file }); 71 if (isXRPCErrorPayload(data)) throw new Error("couldn't upload file"); ··· 77 mimeType: file.type, 78 size: file.size, 79 }; 80 } 81 82 return assets; ··· 86 const { data } = await this.#client.post("com.atproto.repo.putRecord", { 87 input: { 88 repo: this.#did, 89 - collection: "com.jakelazaroff.test", 90 rkey, 91 record: { ...(bundle as any), createdAt: new Date().toISOString() }, 92 }, ··· 96 97 async deleteBundle(rkey: string) { 98 const { data } = await this.#client.post("com.atproto.repo.deleteRecord", { 99 - input: { repo: this.#did, collection: "com.jakelazaroff.test", rkey }, 100 }); 101 102 if (isXRPCErrorPayload(data)) throw new Error(data.error);
··· 33 34 async listBundles() { 35 const { data } = await this.#client.get("com.atproto.repo.listRecords", { 36 + params: { repo: this.#did, collection: "com.jakelazaroff.athost" }, 37 }); 38 39 if (isXRPCErrorPayload(data)) throw new Error("couldn't load records"); ··· 47 }; 48 49 const { data } = await this.#client.post("com.atproto.repo.createRecord", { 50 + input: { repo: this.#did, collection: "com.jakelazaroff.athost", rkey, record }, 51 }); 52 53 if (isXRPCErrorPayload(data)) throw new Error(data.error); ··· 55 56 async getBundle(rkey: string) { 57 const { data } = await this.#client.get("com.atproto.repo.getRecord", { 58 + params: { repo: this.#did, collection: "com.jakelazaroff.athost", rkey }, 59 }); 60 61 if (isXRPCErrorPayload(data)) throw new Error("couldn't load records"); ··· 64 65 async uploadFiles(files: File[]) { 66 const assets: Bundle["assets"] = {}; 67 + let throttle = Promise.resolve(); 68 for (const file of files) { 69 if (!(file instanceof File)) continue; 70 + await throttle; 71 72 const { data } = await this.#client.post("com.atproto.repo.uploadBlob", { input: file }); 73 if (isXRPCErrorPayload(data)) throw new Error("couldn't upload file"); ··· 79 mimeType: file.type, 80 size: file.size, 81 }; 82 + 83 + throttle = new Promise(r => setTimeout(r, 1000)); 84 } 85 86 return assets; ··· 90 const { data } = await this.#client.post("com.atproto.repo.putRecord", { 91 input: { 92 repo: this.#did, 93 + collection: "com.jakelazaroff.athost", 94 rkey, 95 record: { ...(bundle as any), createdAt: new Date().toISOString() }, 96 }, ··· 100 101 async deleteBundle(rkey: string) { 102 const { data } = await this.#client.post("com.atproto.repo.deleteRecord", { 103 + input: { repo: this.#did, collection: "com.jakelazaroff.athost", rkey }, 104 }); 105 106 if (isXRPCErrorPayload(data)) throw new Error(data.error);
+1
src/routes/+layout.ts
··· 1 export const ssr = false;
··· 1 export const ssr = false; 2 + export const prerender = false;
+1 -1
src/routes/~/+page.svelte
··· 17 if (typeof rkey !== "string") throw new Error("invalid rkey"); 18 19 await atp.createBundle(rkey); 20 - await invalidate("collection:com.jakelazaroff.test"); 21 form.reset(); 22 } 23 </script>
··· 17 if (typeof rkey !== "string") throw new Error("invalid rkey"); 18 19 await atp.createBundle(rkey); 20 + await invalidate("collection:com.jakelazaroff.athost"); 21 form.reset(); 22 } 23 </script>
+2 -6
src/routes/~/+page.ts
··· 1 - import type {} from "@atcute/atproto"; 2 - import { Client, isXRPCErrorPayload } from "@atcute/client"; 3 - import { OAuthUserAgent } from "@atcute/oauth-browser-client"; 4 - 5 import { client, configure } from "~/lib/oauth"; 6 7 import type { PageLoad } from "./$types"; ··· 10 configure(); 11 12 export const load: PageLoad = async ({ parent, depends }) => { 13 - depends("collection:com.jakelazaroff.test"); 14 15 try { 16 - const { did, session } = await parent(); 17 18 const atp = client(session); 19 const { records } = await atp.listBundles();
··· 1 import { client, configure } from "~/lib/oauth"; 2 3 import type { PageLoad } from "./$types"; ··· 6 configure(); 7 8 export const load: PageLoad = async ({ parent, depends }) => { 9 + depends("collection:com.jakelazaroff.athost"); 10 11 try { 12 + const { session } = await parent(); 13 14 const atp = client(session); 15 const { records } = await atp.listBundles();
+1 -1
src/routes/~/sites/[name]/+page.svelte
··· 35 const files = formdata.getAll("files").filter(entry => entry instanceof File); 36 const assets = await atp.uploadFiles(files); 37 38 - await atp.updateBundle(rkey, { ...(data.record.value as any), assets }); 39 invalidate(`rkey:${rkey}`); 40 form.reset(); 41 }
··· 35 const files = formdata.getAll("files").filter(entry => entry instanceof File); 36 const assets = await atp.uploadFiles(files); 37 38 + await atp.updateBundle(rkey, { ...(data.record.value as any), description, assets }); 39 invalidate(`rkey:${rkey}`); 40 form.reset(); 41 }
+3 -2
svelte.config.js
··· 1 - import adapter from "@sveltejs/adapter-auto"; 2 import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; 3 4 /** @type {import('@sveltejs/kit').Config} */ 5 const config = { 6 compilerOptions: { experimental: { async: true } }, 7 preprocess: vitePreprocess(), 8 kit: { 9 - adapter: adapter(), 10 alias: { "~/*": "src/*" }, 11 }, 12 };
··· 1 + import adapter from "@sveltejs/adapter-static"; 2 import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; 3 4 /** @type {import('@sveltejs/kit').Config} */ 5 const config = { 6 compilerOptions: { experimental: { async: true } }, 7 preprocess: vitePreprocess(), 8 + 9 kit: { 10 + adapter: adapter({ fallback: "index.html" }), 11 alias: { "~/*": "src/*" }, 12 }, 13 };