Graphical PDS migrator for AT Protocol
1 2import { Agent } from "@atproto/api"; 3import { getSessionAgent } from "../../../lib/sessions.ts"; 4import { define } from "../../../utils.ts"; 5/** 6 * Describe the server configuration and capabilities 7 */ 8export const handler = define.handlers({ 9 async GET(ctx) { 10 const url = new URL(ctx.req.url); 11 const serviceUrl = url.searchParams.get("service"); 12 13 const agent = serviceUrl 14 ? new Agent({ service: serviceUrl }) 15 : await getSessionAgent(ctx.req); 16 if (!agent) { 17 return new Response( 18 serviceUrl ? "Could not create agent." : "Unauthorized", 19 { status: serviceUrl ? 400 : 401 }, 20 ); 21 } 22 const result = await agent.com.atproto.server.describeServer(); 23 return Response.json(result); 24 } 25});