Hooks #
Hooks allow to modify the processing of a payload and its propagation into the associated collections.
beforeProcessing
#
Lifecycle hook executed before processing the payload but after validation
async beforeProcessing (payload: JSONObject, request: KuzzleRequest): Promise<void>
Arguments | Type | Description |
---|---|---|
payload | JSONObject | Raw payload received in the API action body |
request | KuzzleRequest | Original request |
beforeRegister
#
Lifecycle hook executed before a device is registered
async beforeRegister (device: Device, request: KuzzleRequest): Promise<Device>
Arguments | Type | Description |
---|---|---|
device | Device | Device before being persisted |
request | KuzzleRequest | Original request |
Returns #
Returns the enriched device document.
beforeUpdate
#
Lifecycle hook executed before a device is updated
async beforeUpdate (device: Device, request: KuzzleRequest): Promise<Device>
Arguments | Type | Description |
---|---|---|
device | Device | Device before being updated |
request | KuzzleRequest | Original request |
Returns #
Returns the enriched device document.
afterRegister
#
Hook executed after registering a device. The value returned by this method will be used as the API action result.
By default, the device document content is returned.
async afterRegister (device: Device, request: KuzzleRequest): Promise<Device>
Arguments | Type | Description |
---|---|---|
device | Device | Device after being persisted |
request | KuzzleRequest | Original request |
Returns #
Result of the corresponding API action.
afterUpdate
#
Hook executed after updating a device. The value returned by this method will be used as the API action result.
By default, the device document content is returned.
async afterUpdate (device: Device, request: KuzzleRequest): Promise<Device>
Arguments | Type | Description |
---|---|---|
device | Device | Device after being persisted |
request | KuzzleRequest | Original request |
Returns #
Result of the corresponding API action.