+33
-1
scripts/setup.js
+33
-1
scripts/setup.js
···
363
return response.json()
364
}
365
366
+
// === RELAY NOTIFICATION ===
367
+
368
+
async function notifyRelay(relayUrl, pdsHostname) {
369
+
const url = `${relayUrl}/xrpc/com.atproto.sync.requestCrawl`
370
+
371
+
const response = await fetch(url, {
372
+
method: 'POST',
373
+
headers: {
374
+
'Content-Type': 'application/json'
375
+
},
376
+
body: JSON.stringify({
377
+
hostname: pdsHostname
378
+
})
379
+
})
380
+
381
+
// Relay might return 200 or 202, both are OK
382
+
if (!response.ok && response.status !== 202) {
383
+
const text = await response.text()
384
+
console.warn(` Warning: Relay notification returned ${response.status}: ${text}`)
385
+
return false
386
+
}
387
+
388
+
return true
389
+
}
390
+
391
// === MAIN ===
392
393
async function main() {
···
432
console.log(' PDS initialized!')
433
console.log('')
434
435
+
// Step 5: Notify relay
436
+
const pdsHostname = new URL(opts.pds).host
437
+
console.log(`Notifying relay at ${opts.relayUrl}...`)
438
+
const relayOk = await notifyRelay(opts.relayUrl, pdsHostname)
439
+
if (relayOk) {
440
+
console.log(' Relay notified!')
441
+
}
442
+
console.log('')
443
}
444
445
main().catch(err => {