Framework v2.x

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 (opens new window) 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 (opens new window) for more information.

Arguments #

This class constructor takes no argument.

Usage #

Copied to clipboard!
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
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.

Copied to clipboard!
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 #

Copied to clipboard!
KuzzleRequest(originalRequest: KuzzleRequest, requestPayload: RequestPayload, options: JSONObject): KuzzleRequest

Arguments Type Description
Original request of which we will use the context
New request payload
Additional options passed to the RequestContext constructor

Usage #

Copied to clipboard!
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.