0.11.0 • Published 5 months ago

applesauce-core v0.11.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

applesauce-core

AppleSauce Core is an interpretation layer for nostr clients, Push events into the in-memory database and get nicely formatted data out with queries

Example

import { EventStore, QueryStore } from "applesauce-core";
import { Relay } from "nostr-tools/relay";

// The EventStore handles all the events
const eventStore = new EventStore();

// The QueryStore handles queries and makes sure not to run multiple of the same query
const queryStore = new QueryStore(eventStore);

// Use nostr-tools or anything else to talk to relays
const relay = await Relay.connect("wss://relay.example.com");

const sub = relay.subscribe([{ authors: ["266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5"] }], {
  onevent(event) {
    eventStore.add(event);
  },
});

// This will return an Observable<ProfileContent | undefined> of the parsed metadata
const profile = queryStore.profile("266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5");

profile.subscribe((parsed) => {
  if (parsed) console.log(parsed);
});

// This will return an Observable<NostrEvent[]> of all kind 1 events sorted by created_at
const timeline = queryStore.timeline({ kinds: [1] });

timeline.subscribe((events) => {
  console.log(events);
});
0.11.0

6 months ago

0.10.0

8 months ago

0.9.0

9 months ago

0.8.0

10 months ago

0.7.0

10 months ago

0.3.0

11 months ago

0.5.0

11 months ago

0.4.0

11 months ago

0.6.0

11 months ago

0.2.0

11 months ago

0.1.0

11 months ago