Constructors

Methods

  • Broadcast an event. This method does not call any plugins.

    Parameters

    • event: Event

      The event to broadcast

    Returns Promise<void>

  • Destroy the NostrRelay instance. This method should be called when the NostrRelay instance is no longer needed.

    Returns Promise<void>

  • Find events by filters.

    Parameters

    • filters: Filter[]

      Filters

    • Optionalpubkey: string

      Public key of the client

    • Optionaliteratee: ((event: Event) => void)

      Iteratee function to call for each event

        • (event): void
        • Parameters

          Returns void

    Returns Promise<Event[]>

  • Handle a new client connection. This method should be called when a new client connects to the Nostr Relay server.

    Parameters

    • client: Client

      Client instance, usually a WebSocket

    • Optionalip: string

      IP address of the client

    Returns void

  • Handle a client disconnection. This method should be called when a client disconnects from the Nostr Relay server.

    Parameters

    • client: Client

      Client instance, usually a WebSocket

    Returns void

  • Handle an incoming message from a client. It can be an EVENT, REQ, CLOSE, or AUTH message. Before calling this method, you should validate the message by @nostr-relay/validator or other validators.

    Parameters

    • client: Client

      Client instance, usually a WebSocket

    • message: IncomingMessage

      Incoming message from the client

    Returns Promise<HandleMessageResult>

  • Check whether a client is authorized. If NIP-42 is unable, this method always returns true.

    Parameters

    • client: Client

      Client instance, usually a WebSocket

    Returns boolean