Core
Framework v2.x
2

PluginContextConstructors #

The PluginContextConstructors instance is available through the PluginContext.constructors property.

It contains various classes thats allows to interact with Kuzzle.

BaseValidationType #

Abstract class that allows to define a new custom type for the Data Validation module.

ESClient #

This constructor instantiates an embedded Elasticsearch client with the same configuration as the one provided in Kuzzle configuration.

This client can be used to send raw Elasticsearch request.

See Elasticsearch official documentation for more information.

Arguments #

This class constructor takes no argument.

Usage #

const esRequest =  {
  body: {
    name: 'Aschen',
    age: 27
  },
  index: '&nyc-open-data.yellow-taxi',
  op_type: 'create'
}

// Instantiate and use a new client
const esClient = new context.constructors.ESClient()
await esClient.index(esRequest)

Koncorde #

Deprecated since 2.8.0

Instantiates a new Koncorde engine.

The Koncorde class exported by the kuzzle package is itself deprecated since 2.14.0: use the koncorde package (v4) directly.

import { Koncorde } from 'koncorde';

Repository #

Instantiates a new Repository.

Request #

Modified KuzzleRequest constructor. It can instantiate a new KuzzleRequest with the context (user, jwt, connection) of another one, or from raw data.

Arguments #

new Request(originalRequest: KuzzleRequest, requestPayload?: RequestPayload, options?: JSONObject): KuzzleRequest
new Request(requestPayload: RequestPayload, options?: JSONObject): KuzzleRequest

ArgumentsTypeDescription
originalRequest
KuzzleRequest
Original request of which we will use the context. The new request also inherits its _id, index, collection and other arguments, its jwt and its volatile data, unless requestPayload sets them
requestPayload
RequestPayload
New request payload
options
JSONObject
Additional options passed to the RequestContext constructor

The constructor throws a plugin.context.missing_request_data error if its first argument is missing.

Usage #

const req = new context.constructors.Request(request, {
  controller: 'auth',
  action: 'getCurrentUser'
})

const user = await context.accessors.execute(req)

RequestContext #

Deprecated since 2.8.0

The RequestContext class.

The RequestContext class should be imported from the kuzzle package.

import { RequestContext } from 'kuzzle';

RequestInput #

Deprecated since 2.8.0

The RequestInput class.

The RequestInput class should be imported from the kuzzle package.

import { RequestInput } from 'kuzzle';

Mutex #

Available since 2.17.0
Deprecated since 2.57.0

Deprecated: use withLock, exported by kuzzle, instead.

Instantiates a new mutex, allowing to lock a resource. Works both with single-node and cluster environments.

See Mutex documentation for more information.