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.

StorageClient #

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 storageClient = new app.storage.Client()
await storageClient.index(esRequest)

Koncorde #

Deprecated since 2.8.0

Instantiates a new Koncorde engine.

The Koncorde class should be imported from the kuzzle package.

import { Koncorde } from 'kuzzle';

Repository #

Instantiates a new Repository.

KuzzleRequest #

Modified KuzzleRequest constructor that allows to instantiate a new KuzzleRequest with the context (user, jwt, connection) of another one.

Arguments #

KuzzleRequest(originalRequest: KuzzleRequest, requestPayload: RequestPayload, options: JSONObject): KuzzleRequest

ArgumentsTypeDescription
originalRequest
KuzzleRequest
Original request of which we will use the context
requestPayload
RequestPayload
New request payload
options
JSONObject
Additional options passed to the RequestContext constructor

Usage #

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

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

Mutex #

Available since 2.17.0

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

See Mutex documentation for more information.