A zero-dependency AT Protocol Personal Data Server written in JavaScript
atproto pds

feat: add com.atproto.repo.describeRepo endpoint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Changed files
+34
src
+34
src/pds.js
··· 885 885 '/xrpc/com.atproto.repo.getRecord': { 886 886 handler: (pds, req, url) => pds.handleGetRecord(url) 887 887 }, 888 + '/xrpc/com.atproto.repo.describeRepo': { 889 + handler: (pds, req, url) => pds.handleDescribeRepo() 890 + }, 888 891 '/xrpc/com.atproto.sync.getLatestCommit': { 889 892 handler: (pds, req, url) => pds.handleGetLatestCommit() 890 893 }, ··· 1295 1298 return Response.json({ uri, cid: row.cid, value }) 1296 1299 } 1297 1300 1301 + async handleDescribeRepo() { 1302 + const did = await this.getDid() 1303 + if (!did) { 1304 + return Response.json({ error: 'RepoNotFound', message: 'repo not found' }, { status: 404 }) 1305 + } 1306 + const handle = await this.state.storage.get('handle') 1307 + // Get unique collections 1308 + const collections = this.sql.exec( 1309 + `SELECT DISTINCT collection FROM records` 1310 + ).toArray().map(r => r.collection) 1311 + 1312 + return Response.json({ 1313 + handle: handle || did, 1314 + did, 1315 + didDoc: {}, 1316 + collections, 1317 + handleIsCorrect: !!handle 1318 + }) 1319 + } 1320 + 1298 1321 handleGetLatestCommit() { 1299 1322 const commits = this.sql.exec( 1300 1323 `SELECT cid, rev FROM commits ORDER BY seq DESC LIMIT 1` ··· 1440 1463 } 1441 1464 } 1442 1465 return Response.json({ repos, cursor: undefined }) 1466 + } 1467 + 1468 + // describeRepo uses ?repo= param instead of ?did= 1469 + if (url.pathname === '/xrpc/com.atproto.repo.describeRepo') { 1470 + const repo = url.searchParams.get('repo') 1471 + if (!repo) { 1472 + return Response.json({ error: 'InvalidRequest', message: 'missing repo param' }, { status: 400 }) 1473 + } 1474 + const id = env.PDS.idFromName(repo) 1475 + const pds = env.PDS.get(id) 1476 + return pds.fetch(request) 1443 1477 } 1444 1478 1445 1479 const did = url.searchParams.get('did')