store/Rest

Source:

Methods

(async) auth(credentials) → {Promise}

Source:
Parameters:
Name Type Description
credentials object

should contain attributes "user", "password", and "maxAge". MaxAge is the amount of seconds the authorization should be valid.

Returns:

A thenable object

Type
Promise

(async) create(uri, data) → {Promise.<String>}

Description:
  • Posts data to a factory resource with the intent to create a new resource. That is, it posts data and expects a Location header back with information on the created resource.

Source:
Parameters:
Name Type Description
uri string

factory resource, may include parameters.

data string | Object

the data that is to be posted as a string, if an object is provided it will be serialized as json.

Returns:
Type
Promise.<String>

del(uri, modDateopt) → {Promise}

Description:
  • Deletes a resource.

Source:
Parameters:
Name Type Attributes Description
uri String

of the resource that is to be deleted.

modDate Date <optional>

a date to use for the HTTP if-unmodified-since header.

Returns:

A thenable object

Type
Promise

disableCredentials()

Description:
  • Don't allow credentials, i.e. don't send cookies when doing requests.

Source:

disableJSONP()

Description:
  • Disable JSONP for all requests, e.g. when there is a need for performance and there is a need for relable caching which does not work with JSONP.

Source:

enableCredentials()

Description:
  • Allow credentials, i.e. sending cookies, when doing requests.

Source:

enableJSONP()

Description:
  • Enable JSONP for all get requests. JSONP will only be used if EntryStore.js is running in the browser and there are cross-site GET requests. Note that JSONP is enabled in this scenario by default.

Source:

(async) get(uri, format, nonJSONP, writableStream, preventCache) → {Promise}

Description:
  • Fetches data from the provided URI. If a cross-domain call is made and we are in a browser environment a jsonp call is made.

Source:
Parameters:
Name Type Default Description
uri string

URI to a resource to fetch.

format string | null null

the format to request as a mimetype.

nonJSONP boolean false

stop JSONP handling (default false)

writableStream stream

a writable stream to be used in nodejs e.g. for piping data directly to a file

preventCache boolean false

if true an extra argument is added to the uri with a random number to prevent caching

Throws:

Error

Returns:

A thenable object

Type
Promise

post(uri, data, modDateopt, formatopt) → {Promise}

Description:
  • Posts data to the provided URI.

Source:
Parameters:
Name Type Attributes Description
uri String

an URI to post to.

data String | Object

the data to post. If an object the data is sent as form data.

modDate Date <optional>

a date to use for the HTTP if-unmodified-since header.

format string <optional>

indicates the content-type of the data, default is application/json, except if the data is an object in which case the default is multipart/form-data.

Returns:

A thenable object

Type
Promise

put(uri, data, modDateopt, formatopt) → {Promise}

Description:
  • Replaces a resource with a new representation.

Source:
Parameters:
Name Type Attributes Description
uri string

the address to put to.

data string | Object

the data to put. If an object the data is sent as form data.

modDate Date <optional>

a date to use for the HTTP if-unmodified-since header.

format string <optional>

indicates the content-type of the data, default is application/json, except if the data is an object in which case the default is multipart/form-data.

Returns:

A thenable object

Type
Promise

putFile(uri, data, format) → {Promise}

Description:
  • Put a file to a URI. In a browser environment a file is represented via an input tag which references the file to be uploaded via its value attribute. In node environments the file is represented as a stream constructed via fs.createReadStream('file.txt').

    Under the hood the tag is moved into a form in an invisible iframe which then is submitted. If there is a response it is provided in a textarea which can be looked into since we are on the same domain.

Source:
Parameters:
Name Type Description
uri string

the URI to which we will put the file.

data data

input tag or stream that may for instance correspond to a file in a nodejs setting.

format string

the format to handle the response as, either text, xml, html or json (json is default).

Returns:

A thenable object

Type
Promise

setRateLimitationForRead(rateLimtationInstance)

Description:
  • Set up the rate limitation for read requests. The only required method of the instance is the 'enqueue' function, see it's signature in the default RateLimitation class.

Source:
See:
  • RateLimit#enqueue
Parameters:
Name Type Description
rateLimtationInstance Object

setRateLimitationForWrite(rateLimtationInstance)

Description:
  • Set up the rate limitation for write requests. The only required method of the instance is the 'enqueue' function, see it's signature in the default RateLimitation class.

Source:
See:
  • RateLimit#enqueue
Parameters:
Name Type Description
rateLimtationInstance Object