edgeport - v1.0.6
    Preparing search index...

    Function resolve

    Resolves a DNS name in a single call, opening and closing a connection around one query.

    The return type narrows on the requested TYPE (see ResolveResult); A addresses come back as string[], MX as MxRecord[], and so on. NXDOMAIN and "no records" both yield an empty array (never a throw); a server error rcode (SERVFAIL, REFUSED, ...) throws a ProtocolError. Pass server to choose the resolver - inside a Worker this must be a non-Cloudflare resolver such as RESOLVERS.google, because the 1.1.1.1 default is blocked by the runtime.

    The domain name to resolve.

    A record TYPE (name or number) or a ResolveOptions object.

    The resolved records, typed per the TYPE.

    On a server error rcode or a malformed response.

    If the resolver cannot be reached.

    If the query deadline elapses.

    1.0.4

    import { resolve, RESOLVERS } from 'edgeport/dns';

    const a = await resolve('example.com', 'A'); // string[]
    const mx = await resolve('example.com', 'MX'); // MxRecord[]
    const aaaa = await resolve('example.com', { type: 'AAAA', server: RESOLVERS.google });
    • Resolves a name to A records (the default type): the IPv4 addresses as strings.

      Parameters

      • name: string

        The domain name.

      Returns Promise<string[]>

      The IPv4 addresses; empty on NXDOMAIN or no records.

    • Resolves a name to a string array (A/AAAA/NS/CNAME/PTR).

      Parameters

      • name: string
      • type: "A" | "NS" | "CNAME" | "PTR" | "AAAA"

      Returns Promise<string[]>

    • Resolves TXT records (each an array of its character-strings).

      Parameters

      • name: string
      • type: "TXT"

      Returns Promise<string[][]>

    • Resolves MX records.

      Parameters

      • name: string
      • type: "MX"

      Returns Promise<MxRecord[]>

    • Resolves SRV records.

      Parameters

      • name: string
      • type: "SRV"

      Returns Promise<SrvRecord[]>

    • Resolves CAA records.

      Parameters

      • name: string
      • type: "CAA"

      Returns Promise<CaaRecord[]>

    • Resolves the SOA record (or undefined).

      Parameters

      • name: string
      • type: "SOA"

      Returns Promise<SoaRecord | undefined>

    • Resolves NAPTR records.

      Parameters

      • name: string
      • type: "NAPTR"

      Returns Promise<NaptrRecord[]>

    • Resolves SSHFP records.

      Parameters

      • name: string
      • type: "SSHFP"

      Returns Promise<SshfpRecord[]>

    • Resolves DS records.

      Parameters

      • name: string
      • type: "DS"

      Returns Promise<DsRecord[]>

    • Resolves DNSKEY records.

      Parameters

      • name: string
      • type: "DNSKEY"

      Returns Promise<DnskeyRecord[]>

    • Resolves TLSA records.

      Parameters

      • name: string
      • type: "TLSA"

      Returns Promise<TlsaRecord[]>

    • Resolves HTTPS or SVCB service-binding records.

      Parameters

      • name: string
      • type: "SVCB" | "HTTPS"

      Returns Promise<SvcbRecord[]>

    • Resolves RRSIG records.

      Parameters

      • name: string
      • type: "RRSIG"

      Returns Promise<RrsigRecord[]>

    • Resolves the type named in opts.type (with resolver/tls/dnssec options).

      Type Parameters

      • T extends
            | "A"
            | "NS"
            | "CNAME"
            | "SOA"
            | "PTR"
            | "MX"
            | "TXT"
            | "AAAA"
            | "SRV"
            | "NAPTR"
            | "OPT"
            | "DS"
            | "SSHFP"
            | "RRSIG"
            | "NSEC"
            | "DNSKEY"
            | "TLSA"
            | "SVCB"
            | "HTTPS"
            | "CAA"
            | "ANY"

      Parameters

      Returns Promise<ResolveResult<T>>

    • Resolves with options; a numeric or omitted TYPE yields raw records.

      Parameters

      Returns Promise<ResourceRecord[]>

    • Resolves a numeric record TYPE to its raw records.

      Parameters

      • name: string
      • type: number

      Returns Promise<ResourceRecord[]>