src/node/app.ts/ensureAddress
export const ensureAddress = (server: http.Server, protocol: string): URL | string => {
  const addr = server.address()

  if (!addr) {
    throw new Error("Server has no address")
  }

  if (typeof addr !== "string") {
    const host = addr.family === "IPv6" ? `[${addr.address}]` : addr.address
    return new URL(`${protocol}://${host}:${addr.port}`)
  }

  // If this is a string then it is a pipe or Unix socket.
  return addr
}