Cloudflare - v1.3.0
    Preparing search index...

    Interface VpcNetwork

    The runtime shape of a VPC Network binding.

    This interface is a stand-in, and should be deleted rather than maintained. Every other binding type this package wraps comes from @cloudflare/workers-types — Fetcher, Queue, Workflow, Flagship. The pinned version of that package declares nothing for Workers VPC, which is still in beta, so this is the one shape the package describes itself.

    Declaring it is deliberate but not free. A hand-written type cannot be checked against the runtime, so if Cloudflare changes the surface before general availability this compiles happily and fails in production. When @cloudflare/workers-types ships the real type, this file goes and the accessor imports it instead — a change that costs one import and a major version only if the shapes disagree.

    Kept to exactly the two documented methods for that reason. A smaller invented surface is a smaller thing to be wrong about.

    VpcServiceBinding needs no equivalent: a VPC Service binding offers fetch alone, which is Fetcher structurally, so it names a real type.

    1.3.0

    interface VpcNetwork {
        connect(address: string | SocketAddress): Promise<Socket>;
        fetch(
            resource: string | URL | Request<unknown, CfProperties<unknown>>,
            options?: RequestInit,
        ): Promise<Response>;
    }
    Index
    • Opens a TCP socket to a destination on the bound private network.

      Parameters

      • address: string | SocketAddress

        The private destination, as host:port or a SocketAddress.

      Returns Promise<Socket>

      The connected socket.

      For the services that are not HTTP — Redis, Memcached, MQTT, anything speaking its own bytes. Plaintext TCP only at the time of writing.

    • Sends an HTTP request to a destination on the bound private network.

      Parameters

      • resource: string | URL | Request<unknown, CfProperties<unknown>>

        The private destination, as a URL, string, or Request.

      • Optionaloptions: RequestInit

        Standard request options.

      Returns Promise<Response>

      The response from the private service.

      The URL decides the destination, which is the whole difference from a VPC Service — there the binding is pinned to one host and port at deploy time.