Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created December 8, 2022 15:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/a9a359744693861fa6ec2887a6b01715 to your computer and use it in GitHub Desktop.
Save tmcw/a9a359744693861fa6ec2887a6b01715 to your computer and use it in GitHub Desktop.
import { Context } from "https://edge.netlify.com/";
const DOMAIN = "macwright.com";
const USERS = new Map([
[
`acct:photos@macwright.com`,
{
subject: `acct:photos@${DOMAIN}`,
aliases: [],
links: [
{
rel: "http://webfinger.net/rel/profile-page",
type: "text/html",
href: `https://${DOMAIN}/photos`,
},
{
rel: "self",
type: "application/activity+json",
href: `https://${DOMAIN}/u/photos`,
},
],
},
],
]);
export default function handler(req: Request, _context: Context) {
const u = new URL(req.url);
const resource = u.searchParams.get("resource");
if (resource && USERS.has(resource)) {
return new Response(JSON.stringify(USERS.get(resource)), {
status: 200,
headers: { "Content-Type": "application/jrd+json" },
});
}
return new Response("", {
status: 404,
headers: { "Content-Type": "text/html" },
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment