PluginContext #
The PluginContext class is passed to the plugins as an argument of the init method.
It contains various accessors, constructors and helpers that allow to interact with Kuzzle.
accessors #
This property is an instance of the PluginContextAccessors and contains various methods to interact with Kuzzle.
| Type | Description |
|---|---|
PluginContextAccessors | PluginContextAccessors instance |
constructors #
This property is an instance of the PluginContextConstructors and contains various constructors to interact with Kuzzle.
| Type | Description |
|---|---|
PluginContextConstructors | PluginContextConstructors instance |
errors #
This property contains constructors that represent Kuzzle Errors Types.
The usage of this property is deprecated and Kuzzle Errors should be required from the kuzzle package instead.
This property is not available in Typescript.
Available errors:
BadRequestError
ExternalServiceError
ForbiddenError
GatewayTimeoutError
InternalError
KuzzleError
NotFoundError
PartialError
PluginImplementationError
PreconditionError
ServiceUnavailableError
SizeLimitError
TooManyRequestsError
UnauthorizedErrorconfig #
A frozen copy of the whole Kuzzle configuration.
| Type | Description |
|---|---|
JSONObject | Kuzzle configuration (read-only) |
errorsManager #
Alias of kerror. Use kerror instead.
kerror #
Errors manager bound to the plugin domain and to a subdomain named after the plugin. It creates the errors declared in the errors section of the plugin's manifest.json.
| Type | Description |
|---|---|
any | Errors manager |
It exposes the following methods:
| Method | Description |
|---|---|
get(name: string, ...placeholders): KuzzleError | Returns the error defined under name |
getFrom(source: Error, name: string, ...placeholders): KuzzleError | Same as get, keeping the stack trace of source |
reject(name: string, ...placeholders): Promise<never> | Returns a promise rejected with the error |
Usage #
throw context.kerror.get('some_error', 'placeholder value');log #
Kept for backward compatibility only: use logger instead.
A plain object with the debug, error, info, silly, verbose and warn methods. Each one takes a single message and forwards it to logger, prefixed with [<plugin name>]. silly and verbose log with the trace level.
| Type | Description |
|---|---|
JSONObject | Backward-compatible logging methods |
logger #
A child of the Kuzzle logger, with the plugin name as namespace.
It has the trace, debug, info, warn, error, fatal, flush and child methods, and the level property, of the Logger class. It does not have getLevel, setLevel, silly or verbose.
| Type | Description |
|---|---|
KuzzleLogger | Plugin logger (KuzzleLogger from the kuzzle-logger package) |
Usage #
context.logger.info('Plugin initialized');secrets #
This property contains the application secrets that have been made available with the Secrets Vault.
| Type | Description |
|---|---|
JSONObject | Decrypted application secrets |