Home Reference Source Test Repository
import KintoClientBase from 'kinto-client/lib/base.js'
public class | source

KintoClientBase

Direct Subclass:

KintoClient

High level HTTP client for the Kinto API.

Example:

const client = new KintoClient("https://kinto.dev.mozaws.net/v1");
client.bucket("default")
   .collection("my-blog")
   .createRecord({title: "First article"})
  .then(console.log.bind(console))
  .catch(console.error.bind(console));

Constructor Summary

Public Constructor
public

constructor(remote: String, options: Object)

Constructor.

Member Summary

Public Members
public get

Backoff remaining time, in milliseconds.

public get

The remote endpoint base URL.

public get

The current server protocol version, eg.

Method Summary

Public Methods
public

bucket(name: String, options: Object, safe: Boolean, bucket: String, headers: Object): Bucket

Retrieve a bucket object to perform operations on it.

public

Creates a new bucket on the server.

public

Retrieve authenticated user information.

public

Retrieve server capabilities information.

public

Retrieves server information and persist them locally.

public

Retrieves Kinto server settings.

public

fetchUser(options: {}): Promise<Object, Error>

Retrieve authenticated user information.

public

Retrieves the list of buckets.

Public Constructors

public constructor(remote: String, options: Object) source

Constructor.

Params:

NameTypeAttributeDescription
remote String

The remote URL.

options Object

The options object.

options.safe Boolean

Adds concurrency headers to every requests (default: true).

options.events EventEmitter

The events handler. If none provided an EventEmitter instance will be created.

options.headers Object

The key-value headers to pass to each request (default: {}).

options.bucket String

The default bucket to use (default: "default")

options.requestMode String

The HTTP request mode (from ES6 fetch spec).

options.timeout Number

The requests timeout in ms (default: 5000).

Public Members

public get backoff: Number source

Backoff remaining time, in milliseconds. Defaults to zero if no backoff is ongoing.

Test:

public get remote: String source

The remote endpoint base URL. Setting the value will also extract and validate the version.

public get version: String source

The current server protocol version, eg. v1.

Public Methods

public bucket(name: String, options: Object, safe: Boolean, bucket: String, headers: Object): Bucket source

Retrieve a bucket object to perform operations on it.

Params:

NameTypeAttributeDescription
name String

The bucket name.

options Object

The request options.

safe Boolean

The resulting safe option.

bucket String

The resulting bucket name option.

headers Object

The extended headers object option.

Return:

Bucket

Test:

public createBucket(id: String, options: Object): Promise<Object, Error> source

Creates a new bucket on the server.

Params:

NameTypeAttributeDescription
id String

The bucket name.

options Object

The options object.

options.data Boolean

The bucket data option.

options.safe Boolean

The safe option.

options.headers Object

The headers object option.

Return:

Promise<Object, Error>

Test:

public fetchHTTPApiVersion(options: {}): Promise<Object, Error> source

Retrieve authenticated user information.

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

Promise<Object, Error>

Test:

public fetchServerCapabilities(options: {}): Promise<Object, Error> source

Retrieve server capabilities information.

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

Promise<Object, Error>

Test:

public fetchServerInfo(options: Object): Promise<Object, Error> source

Retrieves server information and persist them locally. This operation is usually performed a single time during the instance lifecycle.

Params:

NameTypeAttributeDescription
options Object

The request options.

Return:

Promise<Object, Error>

Test:

public fetchServerSettings(options: {}): Promise<Object, Error> source

Retrieves Kinto server settings.

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

Promise<Object, Error>

Test:

public fetchUser(options: {}): Promise<Object, Error> source

Retrieve authenticated user information.

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

Promise<Object, Error>

Test:

public listBuckets(options: Object): Promise<Object[], Error> source

Retrieves the list of buckets.

Params:

NameTypeAttributeDescription
options Object

The options object.

options.headers Object

The headers object option.

Return:

Promise<Object[], Error>

Test: