Graphical PDS migrator for AT Protocol
1import { resolver } from "../../lib/id-resolver.ts";
2import { define } from "../../utils.ts";
3
4export const handler = define.handlers({
5 async GET(ctx) {
6 const url = new URL(ctx.req.url);
7 const did = url.searchParams.get("did");
8
9 if (!did) {
10 return new Response(
11 JSON.stringify({ error: "DID parameter is required" }),
12 {
13 status: 400,
14 headers: { "Content-Type": "application/json" },
15 },
16 );
17 }
18
19 try {
20 const pds = await resolver.resolveDidToPdsUrl(did);
21 return new Response(JSON.stringify({ pds }), {
22 status: 200,
23 headers: { "Content-Type": "application/json" },
24 });
25 } catch (error) {
26 console.error("Failed to resolve PDS:", error);
27 return new Response(JSON.stringify({ error: "Failed to resolve PDS" }), {
28 status: 500,
29 headers: { "Content-Type": "application/json" },
30 });
31 }
32 },
33});