+21
src/pds.js
+21
src/pds.js
···
680
680
681
681
return Response.json({ uri, cid: row.cid, value })
682
682
}
683
+
if (url.pathname === '/xrpc/com.atproto.sync.getRepo') {
684
+
const commits = this.sql.exec(
685
+
`SELECT cid FROM commits ORDER BY seq DESC LIMIT 1`
686
+
).toArray()
687
+
688
+
if (commits.length === 0) {
689
+
return Response.json({ error: 'repo not found' }, { status: 404 })
690
+
}
691
+
692
+
const blocks = this.sql.exec(`SELECT cid, data FROM blocks`).toArray()
693
+
// Convert ArrayBuffer data to Uint8Array
694
+
const blocksForCar = blocks.map(b => ({
695
+
cid: b.cid,
696
+
data: new Uint8Array(b.data)
697
+
}))
698
+
const car = buildCarFile(commits[0].cid, blocksForCar)
699
+
700
+
return new Response(car, {
701
+
headers: { 'content-type': 'application/vnd.ipld.car' }
702
+
})
703
+
}
683
704
return new Response('pds running', { status: 200 })
684
705
}
685
706
}