NiceRelay
import { NiceRelay } from "https://gitlab.com/soapbox-pub/nostr-machina/-/raw/main/mod.ts";
Opinionated relay implementation that manages subscriptions and auto-reconnects.
class NiceRelay { }
constructor(url: string | URL, opts?: NiceRelayOpts);
socket: WebSocket;
async close();
async send(msg: ["EVENT", {
id: string;
}], opts?: SendOpts): Promise<RelayOK | void>;async send(msg: [string, ...unknown[]], opts?: SendOpts): Promise<void>;
async send(msg: [string, ...unknown[]], opts?: SendOpts): Promise<RelayOK | void>;
§Properties
§Methods
§
Subscribe to events from the relay.
@example
const sub = relay.req([
{ kinds: [1], authors: ['79c2...'] },
]);
for await (const event of sub) {
handleEvent(event);
}
§
send(msg: ["EVENT", {
[src]id: string;
}], opts?: SendOpts): Promise<RelayOK | void>Send a message to the relay, and wait for the OK
if it's an event message.
send(msg: [string, ...unknown[]], opts?: SendOpts): Promise<void>
[src]send(msg: [string, ...unknown[]], opts?: SendOpts): Promise<RelayOK | void>
[src]