[WIP] A (somewhat barebones) atproto app for creating custom sites without hosting!

server: simple html index landing page

+48 -5
+1 -1
deno.json
··· 2 2 "tasks": { 3 3 "dev": "PORT=8000 deno run --watch --allow-net --allow-env=HOSTNAME,PORT main.ts" 4 4 }, 5 - "imports": {} 5 + "unstable": ["raw-imports"] 6 6 }
+31
index/index.html
··· 1 + <!doctype html> 2 + <html lang="en"> 3 + <head> 4 + <meta charset="UTF-8" /> 5 + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 6 + <title>atcities.dev</title> 7 + 8 + <style> 9 + :root { 10 + color-scheme: light dark; 11 + } 12 + 13 + dt { 14 + font-weight: bold; 15 + } 16 + </style> 17 + </head> 18 + <body> 19 + <h1>atcities.dev</h1> 20 + <dl> 21 + <dt>Visit someones site by handle:</dt> 22 + <dd>Head to <code>https://HANDLE.atcities.dev</code></dd> 23 + 24 + <dt>Visit someones site by DID:</dt> 25 + <dd>Head to <code>https://DID.DID-METHOD.atcities.dev</code></dd> 26 + 27 + <dt>Create your own site:</dt> 28 + <dd>Suffer</dd> 29 + </dl> 30 + </body> 31 + </html>
+3 -4
main.ts
··· 1 + import root from "./root.ts"; 2 + 1 3 const ROOT_DOMAIN = Deno.env.get("HOSTNAME") || "localhost"; 2 4 const PORT = Number(Deno.env.get("PORT")) || 80; 3 5 ··· 19 21 }); 20 22 } 21 23 22 - if (subdomain.length === 1 && subdomain[0] === "www") 23 - return new Response("Index site not implemented", { 24 - status: 501, 25 - }); 24 + if (subdomain.length === 1 && subdomain[0] === "www") return root(req); 26 25 27 26 // did:plc example: `sjkdgfjk.did-plc.ROOT_DOMAIN` 28 27 // did:web example: `vielle.dev.did-web.ROOT_DOMAIN
+13
root.ts
··· 1 + import index from "./index/index.html" with { type: "text" }; 2 + 3 + export default function (req: Request) { 4 + if (new URL(req.url).pathname === "/") 5 + return new Response(index, { 6 + headers: { 7 + "Content-Type": "text/html; charset=utf8", 8 + }, 9 + }); 10 + return new Response("404", { 11 + status: 404, 12 + }); 13 + }