this repo has no description
atproto bluesky typescript express

PLC resolver

+25 -1
+21
src/lib/resolver.ts
··· 53 53 return null; 54 54 } 55 55 } 56 + 57 + export async function byPLC( 58 + did: string, 59 + endpoint: string = "https://plc.directory", 60 + ) { 61 + const agent = new Agent({ keepAliveTimeout: 10000 }); 62 + setGlobalDispatcher(agent); 63 + 64 + try { 65 + const response = await fetch(`${endpoint}/${did}`); 66 + const data = await response.json(); 67 + 68 + if (!data) { 69 + return null; 70 + } else { 71 + return data; 72 + } 73 + } catch (e) { 74 + return null; 75 + } 76 + }
+4 -1
src/tests/resolver.test.ts
··· 1 - import { byDNS, byHTTP } from "../lib/resolver.js"; 1 + import { byDNS, byHTTP, byPLC } from "../lib/resolver.js"; 2 2 3 3 byDNS("yoyle.city").then((result) => console.log("DNS: " + result)); 4 4 byHTTP("yoyle.city").then((result) => console.log("HTTP: " + result)); 5 + byPLC("did:plc:vro3sykit2gjemuza2pwvxwy").then((result) => 6 + console.log("PLC: " + JSON.stringify(result)), 7 + );