snort/packages/system
kieran 80a4b5d8e6
continuous-integration/drone/push Build is failing Details
feat: UserState
2024-04-22 14:38:14 +01:00
..
examples refactor: reactions grouping and other fixes 2024-01-09 16:40:31 +00:00
src feat: UserState 2024-04-22 14:38:14 +01:00
tests feat: UserState 2024-04-22 14:38:14 +01:00
.npmignore cleanup 2023-06-09 00:43:21 +02:00
README.md refactor: reactions grouping and other fixes 2024-01-09 16:40:31 +00:00
jest.config.js optimize 2023-06-12 14:15:45 +01:00
package.json fix: duplicate relays 2024-02-29 12:11:21 +00:00
tsconfig.json feat: nip46 oAuth login 2024-02-15 11:28:09 +00:00
typedoc.json chore: Update translations 2024-01-12 13:55:39 +00:00

README.md

@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";

// Singleton instance to store all connections and access query fetching system
const System = new NostrSystem({});

(async () => {
  // Setup cache system
  await System.Init();

  // connec to one "bootstrap" relay to pull profiles/relay lists from
  // also used as a fallback relay when gossip model doesnt know which relays to pick, or "authors" are not provided in the request
  await System.ConnectToRelay("wss://relay.snort.social", { read: true, write: false });

  // ID should be unique to the use case, this is important as all data fetched from this ID will be merged into the same NoteStore
  const rb = new RequestBuilder("get-posts");
  rb.withFilter()
    .authors(["63fe6318dc58583cfe16810f86dd09e18bfd76aabc24a0081ce2856f330504ed"]) // Kieran pubkey
    .kinds([1])
    .limit(10);

  const q = System.Query(rb);
  // basic usage using "onEvent", fired every 100ms
  q.on("event", evs => {
    console.log(evs);
    // something else..
  });
})();