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

server: use the mime type from the blob

anything else is lowk stupid lmfao
like you can set whatever mime type you want why would you not do that

+14 -30
-4
lex/dev.atcities.route.json
··· 13 13 "page": { 14 14 "type": "blob", 15 15 "accept": ["*/*"] 16 - }, 17 - "mimeType": { 18 - "type": "string", 19 - "description": "Optionally the mime type for this page. `mimeType` > `blob.mimeType` (ignore application/octet-stream) > getBlob xrpc mime header" 20 16 } 21 17 }, 22 18 "required": ["page"]
-1
src/lexicons/types/dev/atcities/route.ts
··· 6 6 /*#__PURE__*/ v.string(), 7 7 /*#__PURE__*/ v.object({ 8 8 $type: /*#__PURE__*/ v.literal("dev.atcities.route"), 9 - mimeType: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), 10 9 page: /*#__PURE__*/ v.blob(), 11 10 }), 12 11 );
+14 -25
src/user.ts
··· 174 174 } 175 175 176 176 if (is(DevAtcitiesRoute.mainSchema, record_data.value)) { 177 - const { 178 - ok: blob_ok, 179 - data: blob_data, 180 - headers: blob_headers, 181 - } = await client.get("com.atproto.sync.getBlob", { 182 - params: { 183 - did, 184 - cid: 185 - "ref" in record_data.value.page 186 - ? record_data.value.page.ref.$link 187 - : record_data.value.page.cid, 188 - }, 189 - as: "stream", 190 - }); 177 + const { ok: blob_ok, data: blob_data } = await client.get( 178 + "com.atproto.sync.getBlob", 179 + { 180 + params: { 181 + did, 182 + cid: 183 + "ref" in record_data.value.page 184 + ? record_data.value.page.ref.$link 185 + : record_data.value.page.cid, 186 + }, 187 + as: "stream", 188 + } 189 + ); 191 190 192 191 // possible errors include: 193 192 // - request issue ··· 215 214 216 215 return new Response(blob_data, { 217 216 headers: { 218 - "Content-Type": 219 - (record_data.value.mimeType ?? 220 - record_data.value.page.mimeType !== "application/octet-stream") 221 - ? record_data.value.page.mimeType 222 - : (blob_headers.get("Content-Type") ?? 223 - "application/octet-stream"), 217 + "Content-Type": record_data.value.page.mimeType, 224 218 }, 225 219 }); 226 220 ··· 229 223 return new Response( 230 224 "Malformed record for at://" + did + "/dev.atcities.route/" + targetRkey 231 225 ); 232 - 233 - return new Response("Loading " + targetRkey, { 234 - status: 404, 235 - statusText: "Not Found", 236 - }); 237 226 } catch (e) { 238 227 console.error(e); 239 228 return new Response("Something went wrong loading this route", {