Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "connection"

import type { Config } from "arangojs/connection";

The "connection" module provides connection and configuration related types for TypeScript.

Index

Type aliases

AgentOptions

AgentOptions: NodeAgentOptions | XhrOptions

Options for creating the Node.js http.Agent or https.Agent.

In browser environments this option can be used to pass additional options to the underlying calls of the xhr module.

See also http.Agent and https.Agent (when using TLS).

ArangoResponseMetadata

ArangoResponseMetadata: { code: number; error: false }

Generic properties shared by all ArangoDB HTTP API responses.

Type declaration

  • code: number

    Response status code, typically 200.

  • error: false

    Indicates that the request was successful.

BasicAuthCredentials

BasicAuthCredentials: { password?: undefined | string; username: string }

Credentials for HTTP Basic authentication.

Type declaration

  • Optional password?: undefined | string

    Password to use for authentication. Defaults to an empty string.

  • username: string

    Username to use for authentication, e.g. "root".

BearerAuthCredentials

BearerAuthCredentials: { token: string }

Credentials for HTTP Bearer token authentication.

Type declaration

  • token: string

    Bearer token to use for authentication.

Config

Config: { agent?: any; agentOptions?: AgentOptions & RequestInterceptors; arangoVersion?: undefined | number; auth?: BasicAuthCredentials | BearerAuthCredentials; databaseName?: undefined | string; headers?: Headers; loadBalancingStrategy?: LoadBalancingStrategy; maxRetries?: false | number; precaptureStackTraces?: undefined | false | true; url?: string | string[] }

Options for configuring arangojs.

Type declaration

  • Optional agent?: any

    An http Agent instance to use for connections.

    By default a new Agent instance will be created using the agentOptions.

    This option has no effect when using the browser version of arangojs.

    See also: http.Agent and https.Agent (when using TLS).

  • Optional agentOptions?: AgentOptions & RequestInterceptors

    Options used to create that underlying HTTP/HTTPS Agent (or the xhr module when using arangojs in the browser). This will be ignored if agent is also provided.

    The option maxSockets can also be used to limit how many requests arangojs will perform concurrently. The maximum number of requests is equal to maxSockets * 2 with keepAlive: true or equal to maxSockets with keepAlive: false (or in the browser).

    Default (Node.js): { maxSockets: 3, keepAlive: true, keepAliveMsecs: 1000 }

    Default (browser): { maxSockets: 3, useXDR: true, withCredentials: true }

  • Optional arangoVersion?: undefined | number

    Numeric representation of the ArangoDB version the driver should expect. The format is defined as XYYZZ where X is the major version, Y is the zero-filled two-digit minor version and Z is the zero-filled two-digit bugfix version, e.g. 30102 for 3.1.2, 20811 for 2.8.11.

    Depending on this value certain methods may become unavailable or change their behavior to remain compatible with different versions of ArangoDB.

    Default: 30400

  • Optional auth?: BasicAuthCredentials | BearerAuthCredentials

    Credentials to use for authentication.

    See also Database.useBasicAuth and Database.useBearerAuth.

    Default: { username: "root", password: "" }

  • Optional databaseName?: undefined | string

    Name of the database to use.

    Default: "_system"

  • Optional headers?: Headers

    An object with additional headers to send with every request.

    If an "authorization" header is provided, it will be overridden when using Database.useBasicAuth, Database.useBearerAuth or the auth configuration option.

  • Optional loadBalancingStrategy?: LoadBalancingStrategy

    Determines the behavior when multiple URLs are provided:

    • "NONE": No load balancing. All requests will be handled by the first URL in the list until a network error is encountered. On network error, arangojs will advance to using the next URL in the list.

    • "ONE_RANDOM": Randomly picks one URL from the list initially, then behaves like "NONE".

    • "ROUND_ROBIN": Every sequential request uses the next URL in the list.

    Default: "NONE"

  • Optional maxRetries?: false | number

    Determines the behavior when a request fails because the underlying connection to the server could not be opened (i.e. ECONNREFUSED in Node.js):

    • false: the request fails immediately.

    • 0: the request is retried until a server can be reached but only a total number of times matching the number of known servers (including the initial failed request).

    • any other number: the request is retried until a server can be reached the request has been retried a total of maxRetries number of times (not including the initial failed request).

    When working with a single server without leader/follower failover, the retries (if any) will be made to the same server.

    This setting currently has no effect when using arangojs in a browser.

    Note: Requests bound to a specific server (e.g. fetching query results) will never be retried automatically and ignore this setting.

    Default: 0

  • Optional precaptureStackTraces?: undefined | false | true

    If set to true, arangojs will generate stack traces every time a request is initiated and augment the stack traces of any errors it generates.

    Warning: This will cause arangojs to generate stack traces in advance even if the request does not result in an error. Generating stack traces may negatively impact performance.

  • Optional url?: string | string[]

    Base URL of the ArangoDB server or list of server URLs.

    When working with a cluster or a single server with leader/follower failover, the method Database.acquireHostList can be used to automatically pick up additional coordinators/followers at any point.

    When running ArangoDB on a unix socket, e.g. /tmp/arangodb.sock, the following URL formats are supported for unix sockets:

    • unix:///tmp/arangodb.sock (no SSL)
    • http+unix:///tmp/arangodb.sock (or https+unix:// for SSL)
    • http://unix:/tmp/arangodb.sock (or https://unix: for SSL)

    Additionally ssl and tls are treated as synonymous with https and tcp is treated as synonymous with http, so the following URLs are considered identical:

    • tcp://localhost:8529 and http://localhost:8529
    • ssl://localhost:8529 and https://localhost:8529
    • tcp+unix:///tmp/arangodb.sock and http+unix:///tmp/arangodb.sock
    • ssl+unix:///tmp/arangodb.sock and https+unix:///tmp/arangodb.sock
    • tcp://unix:/tmp/arangodb.sock and http://unix:/tmp/arangodb.sock
    • ssl://unix:/tmp/arangodb.sock and https://unix:/tmp/arangodb.sock

    See also auth for passing authentication credentials.

    Default: "http://localhost:8529"

Dict

Dict<T>: {}

Generic type representing an object with values of a given value type.

Type parameters

  • T

    Type of the object's property values.

Type declaration

  • [key: string]: T

Headers

Headers: Dict<string>

An arbitrary object with string values representing HTTP headers and their values.

Header names should always be lowercase.

LoadBalancingStrategy

LoadBalancingStrategy: "NONE" | "ROUND_ROBIN" | "ONE_RANDOM"

Determines the behavior when multiple URLs are used:

  • "NONE": No load balancing. All requests will be handled by the first URL in the list until a network error is encountered. On network error, arangojs will advance to using the next URL in the list.

  • "ONE_RANDOM": Randomly picks one URL from the list initially, then behaves like "NONE".

  • "ROUND_ROBIN": Every sequential request uses the next URL in the list.

Params

Params: Dict<any>

An arbitrary object with scalar values representing query string parameters and their values.

RequestInterceptors

RequestInterceptors: { after?: undefined | ((err: ArangojsError | null, res?: ArangojsResponse) => void); before?: undefined | ((req: ClientRequest) => void) }

Additional options for intercepting the request/response. These methods are primarily intended for tracking network related metrics.

Type declaration

  • Optional after?: undefined | ((err: ArangojsError | null, res?: ArangojsResponse) => void)

    Callback that will be invoked when the server response has been received and processed or when the request has been failed without a response.

    The originating request will be available as the request property on either the error or response object.

    param

    Error encountered when handling this request or null.

    param

    Response object for this request, if no error occurred.

  • Optional before?: undefined | ((req: ClientRequest) => void)

    Callback that will be invoked with the finished request object before it is finalized. In the browser the request may already have been sent.

    param

    Request object or XHR instance used for this request.

RequestOptions

RequestOptions: { allowDirtyRead?: undefined | false | true; basePath?: undefined | string; body?: any; expectBinary?: undefined | false | true; headers?: Headers; host?: undefined | number; isBinary?: undefined | false | true; method?: undefined | string; path?: undefined | string; qs?: string | Params; timeout?: undefined | number }

Options for performing a request with arangojs.

Type declaration

  • Optional allowDirtyRead?: undefined | false | true

    Whether ArangoDB is allowed to perform a dirty read to respond to this request. If set to true, the response may reflect a dirty state from a non-authoritative server.

  • Optional basePath?: undefined | string

    Optional prefix path to prepend to the path.

  • Optional body?: any

    Request body data.

  • Optional expectBinary?: undefined | false | true

    If set to true, the response body will not be interpreted as JSON and instead passed as-is.

  • Optional headers?: Headers

    HTTP headers to pass along with this request in addition to the default headers generated by arangojs.

  • Optional host?: undefined | number
    internal

    Identifier of a specific ArangoDB host to use when more than one is known.

  • Optional isBinary?: undefined | false | true

    If set to true, the request body will not be converted to JSON and instead passed as-is.

  • Optional method?: undefined | string

    HTTP method to use in order to perform the request.

    Default: "GET"

  • Optional path?: undefined | string

    URL path, relative to the basePath and server domain.

  • Optional qs?: string | Params

    URL parameters to pass as part of the query string.

  • Optional timeout?: undefined | number

    Time in milliseconds after which arangojs will abort the request if the socket has not already timed out.

    See also agentOptions.timeout in Config.

XhrOptions

XhrOptions: { beforeSend?: undefined | ((xhrObject: any) => void); maxSockets?: undefined | number; timeout?: undefined | number; useXdr?: undefined | false | true; withCredentials?: undefined | false | true; xhr?: any }

Options of the xhr module that can be set using agentOptions when using arangojs in the browser. Additionally maxSockets can be used to control the maximum number of parallel requests.

See also: xhr on npm.

Type declaration

  • Optional beforeSend?: undefined | ((xhrObject: any) => void)

    Callback that will be invoked immediately before the send method of the request is called.

    See also RequestInterceptors.

  • Optional maxSockets?: undefined | number

    Maximum number of parallel requests arangojs will perform. If any additional requests are attempted, they will be enqueued until one of the active requests has completed.

  • Optional timeout?: undefined | number

    Number of milliseconds to wait for a response.

    Default: 0 (disabled)

  • Optional useXdr?: undefined | false | true

    (Internet Explorer 10 and lower only.) Whether XDomainRequest should be used instead of XMLHttpRequest. Only required for performing cross-domain requests in older versions of Internet Explorer.

  • Optional withCredentials?: undefined | false | true

    Specifies whether browser credentials (e.g. cookies) should be sent if performing a cross-domain request.

    See XMLHttpRequest.withCredentials.

  • Optional xhr?: any

    XMLHttpRequest object to use instead of the native implementation.

Generated using TypeDoc