serve a static website from your pds

Try to deploy

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