Skip to main content
Module

x/feathers/mod.ts>HookContext

The API and real-time application framework
Go to Latest
interface HookContext
Re-export
import { type HookContext } from "https://deno.land/x/feathers@v5.0.0-pre.32/mod.ts";

Type Parameters

optional
A = Application
optional
S = any

Properties

readonly
app: A

A read only property that contains the Feathers application object. This can be used to retrieve other services (via context.app.service('name')) or configuration values.

readonly
method: string

A read only property with the name of the service method (one of find, get, create, update, patch, remove).

readonly
path: string

A read only property and contains the service name (or path) without leading or trailing slashes.

readonly
service: S

A read only property and contains the service this hook currently runs on.

readonly
type:
| null
| "before"
| "after"
| "error"

A read only property with the hook type (one of before, after or error). Will be null for asynchronous hooks.

readonly
arguments: any[]

The list of method arguments. Should not be modified, modify the params, data and id properties instead.

optional
data: ServiceGenericData<S>

A writeable property containing the data of a create, update and patch service method call.

optional
error: any

A writeable property with the error object that was thrown in a failed method call. It is only available in error hooks.

optional
id: Id

A writeable property and the id for a get, remove, update and patch service method call. For remove, update and patch context.id can also be null when modifying multiple entries. In all other cases it will be undefined.

params: Params

A writeable property that contains the service method parameters (including params.query).

optional
result: ServiceGenericType<S>

A writeable property containing the result of the successful service method call. It is only available in after hooks.

context.result can also be set in

  • A before hook to skip the actual service method (database) call
  • An error hook to swallow the error and return a result instead
optional
dispatch: ServiceGenericType<S>

A writeable, optional property and contains a 'safe' version of the data that should be sent to any client. If context.dispatch has not been set context.result will be sent to the client instead.

optional
statusCode: number

A writeable, optional property that allows to override the standard HTTP status code that should be returned.

event: string | null

The event emitted by this method. Can be set to null to skip event emitting.