nostrbasedocs
Start building
API reference
.md

Read the backups guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.

Backup

interface Backup {
  format: "nostrbase-backup";
  version: 1;
  namespace: string;
  exportedAt: number;
  events: NostrEvent[];
}

BackupImport

interface BackupImport {
  imported: number;
  duplicates: number;
}

belongsToNamespace

declare function belongsToNamespace(
  event: NostrEvent,
  namespace: string,
  known?: ReadonlySet<string>,
): boolean;

NostrbaseBackup

declare class NostrbaseBackup {}

constructor

constructor(host: BackupHost);

export

export(): Promise<Result<Backup>>;

import

import(input: Backup | string): Promise<Result<BackupImport>>;

Supporting declarations

These types appear in public signatures but are not package exports.

BackupHost

interface BackupHost {
  namespace: string;
  eventStore: EventStore;
  cachedEvents(): NostrEvent[];
  ready(): Promise<void>;
  assertOpen(): void;
  ingest(event: NostrEvent): boolean;
}

Search guides, API methods, and protocols.