diff --git a/src/index.ts b/src/index.ts index f391d15..594aafe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,7 @@ addHandler("registrySubscription", handleRegistrySubscription, { receiveUpdates: true, }); addHandler("cat", handleCat); +addHandler("stat", handleStat); async function handlePresentKey(aq: ActiveQuery) { handlePresentKeyModule({ @@ -197,3 +198,16 @@ async function handleCat(aq: ActiveQuery) { aq.reject(e); } } +async function handleStat(aq: ActiveQuery) { + if (!("cid" in aq.callerInput)) { + aq.reject("cid required"); + return; + } + + try { + const ret = await node.getMetadataByCID(aq.callerInput.cid); + aq.respond(ret.toJson()); + } catch (e) { + aq.reject(e); + } +}