Skip to content

Instantly share code, notes, and snippets.

@iameli
Created December 16, 2025 01:02
Show Gist options
  • Select an option

  • Save iameli/1e0262a2fcad35cd0b6795af1343f26a to your computer and use it in GitHub Desktop.

Select an option

Save iameli/1e0262a2fcad35cd0b6795af1343f26a to your computer and use it in GitHub Desktop.
const posts = {
a: {
post: "at://did:plc:3lrf6zdan6pmjgd2ohrnyl3q/app.bsky.feed.post/3m4ex76jc6k2k",
},
b: {
post: "at://did:plc:ctyblsrpmm3e76zkog6ydfuz/app.bsky.feed.post/3ma2qdyjecj2x",
},
c: {
post: "at://did:plc:glgectzqorlgja3zhgyxfaff/app.bsky.feed.post/3m7gbu7xhbt2z",
},
d: {
post: "at://did:plc:2zmxikig2sj7gqaezl5gntae/app.bsky.feed.post/3ma2o3hbxcm2j",
},
e: {
post: "at://did:plc:3i6uzuatdyk7rwfkrybynf5j/app.bsky.feed.post/3m7z6ajkvfn22",
},
};
const did = {
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/multikey/v1",
"https://w3id.org/security/suites/secp256k1-2019/v1"
],
"id": "did:web:broken-mouse-78a0.stream-624.workers.dev",
"service": [
{
"id": "#bsky_fg",
"serviceEndpoint": "https://broken-mouse-78a0.stream-624.workers.dev",
"type": "BskyFeedGenerator"
}
]
}
export default {
async fetch(request, env, ctx) {
const u = new URL(request.url);
if (u.pathname === "/.well-known/did.json") {
return Response.json(did);
}
if (u.pathname !== "/xrpc/app.bsky.feed.getFeedSkeleton") {
return new Response("only supported route: /xrpc/app.bsky.feed.getFeedSkeleton", {status: 404});
}
const feed = u.searchParams.get("feed");
if (!feed) {
return new Response("?feed=aturi parameter is required", {status: 400});
}
const parts = feed.split("/");
if (parts.length !== 5) {
return new Response("?feed should be in format at://did:plc:examlpe/app.bsky.feed.generator/a-b-c-d-e", {status: 400});
}
const feedName = parts[4];
const feedParts = feedName.split("-");
const res = [];
for (const part of feedParts) {
if (!posts[part]) {
return new Response(`unknown post name "${part}". Allowed posts: ${JSON.stringify(Object.keys(posts))}`)
}
res.push(posts[part]);
}
return Response.json({feed: res});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment