Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/lophus/core/nodes.ts>NostrNode

Fully-modular TypeScript implementation of the Nostr protocol, oriented to web standards and edge environments
Latest
interface NostrNode
import { type NostrNode } from "https://deno.land/x/lophus@0.0.13/core/nodes.ts";

Common interface for relays and clients, which extends EventTarget.

Properties

readonly
config: Readonly<NostrNodeConfig<W, R>>
readonly
ws: WebSocketLike
readonly
writable: WritableStream<W>
status: WebSocketLike["readyState"]

Methods

send(msg: W): void | Promise<void>
close(): Promise<void>
install(mod: NostrNodeModule<W, R>): void
addEventListener<T extends EventType<R>>(
type: T,
listener: NostrNodeEventListenerOrEventListenerObject<W, R, T> | null,
): void
removeEventListener<T extends EventType<R>>(
type: T,
listener: NostrNodeEventListenerOrEventListenerObject<W, R, T> | null,
options?: boolean | EventListenerOptions,
): void
dispatchEvent<T extends EventType<R>>(event: NostrNodeEvent<R, T>): boolean
dispatch<T extends EventType<R>>(type: T, data: R[T]): void

A convenience method to dispatch a NostrNodeEvent with the given type and data.

on<T extends EventType<R>>(type: T, listener: (data: R[T]) => any): void

A convenience method to add an event listener for the given type that calls the given listener when the event is dispatched.