edgeport - v1.0.3
    Preparing search index...

    Interface NatsMessage

    A message delivered to a NatsSubscription or returned by a request.

    1.0.0

    interface NatsMessage {
        data: Uint8Array;
        reply?: string;
        sid: string;
        subject: string;
        json<T = unknown>(): T;
        respond?(value: unknown): Promise<void>;
        text(): string;
    }
    Index
    data: Uint8Array

    The raw payload bytes.

    reply?: string

    The reply subject, when the publisher set one (request-reply).

    sid: string

    The subscription id that received it.

    subject: string

    The subject the message was published to.

    • Decodes the payload as UTF-8 then parses it as JSON.

      Type Parameters

      • T = unknown

        The expected shape of the decoded value.

      Returns T

      The parsed value.

      If the payload is not valid JSON.

      1.0.2

    • Publishes a JSON reply to this message's NatsMessage.reply subject.

      Only present when the message carries a reply subject (a request); calling it otherwise throws. The value is JSON.stringify-ed and published as UTF-8.

      Parameters

      • value: unknown

        The value to serialize and publish.

      Returns Promise<void>

      Resolves once the reply PUB frame is written.

      If the message has no reply subject.

      1.0.2

    • Decodes the payload as UTF-8 text.

      Returns string

      The payload as a string.

      1.0.2