@snort/system
A collection of caching and querying techniquies used by https://snort.social to serve all content from the nostr protocol.
Simple example:
import {
NostrSystem,
RequestBuilder,
StoreSnapshot,
NoteCollection
} from "@snort/system"
const System = new NostrSystem({});
(async () => {
await System.Init();
await System.ConnectToRelay("wss://relay.snort.social", { read: true, write: false });
const rb = new RequestBuilder("get-posts");
rb.withFilter()
.authors(["63fe6318dc58583cfe16810f86dd09e18bfd76aabc24a0081ce2856f330504ed"])
.kinds([1])
.limit(10);
const q = System.Query(NoteCollection, rb);
q.feed.onEvent(evs => {
console.log(evs);
});
const release = q.feed.hook(() => {
const state = q.feed.snapshot as StoreSnapshot<ReturnType<NoteCollection["getSnapshotData"]>>;
console.log(`We have ${state.data?.length} events now!`);
});
release();
})();