Skip to content

debugging

Makes a call observable — logging, serializing, inspecting context.

NameCategoryDescription
debug
hooks

Logs the current hook context to the console for debugging purposes. Displays timestamp, service path, method, type, id, data, query, result, and any additional param fields you specify.

contextToJson
utils

Converts a FeathersJS HookContext to a plain JSON object by calling toJSON() if available. This is important when using lodash get/has on the context, since the HookContext class uses getters that may not be enumerable.

stringifyParams
utils

Serializes Feathers params into a stable, deterministic string — built for generating cache keys.

Two normalizations make semantically-equal params produce the same string:

  • sortObject: object keys are sorted recursively.
  • sortArray: elements of query array operators ($or, $and, $nor, $not, $in, $nin) are order-normalized.

Serialization is crash-safe and never throws on values that leak through a params whitelist: circular references become [Circular], functions/undefined/symbol are dropped (like JSON.stringify), BigInt is stringified, and objects with toJSON (e.g. Date, bson ObjectId) are serialized via it.

recordHooks
testing

Record every call that passes through a service or an application, so a test can assert what was requested — and how often — without standing up a spy per method.

Pass an app to record all of its services, or a single service to record just that one; path, method and type narrow it further. The typical use is proving a cache, a debounce or a local-first store did not go to the server, which is awkward to assert on results alone.

The record is indexed by hook type and method — calls.before.get — and every entry is a plain array, so it composes with any predicate, isContext included. So do reset() and waitFor().

By default the live HookContext is recorded. That object keeps mutating as the call travels through the remaining hooks, so if you assert on data or params.query after the call resolved, pass snapshot: true.

See all tags for the full vocabulary.

Released under the MIT License.