# Hooks

Weacast core module (opens new window) and client module (opens new window) provides a collection of common hooks (opens new window) to be used by plugins or client applications (opens new window). They also rely on Feathers common hooks (opens new window).

TIP

Hooks (opens new window) are the main way to introduce business logic into applications and plugins so we recommend to understand them well first before reading this.

# Data model management

source (opens new window)

# .marshall(hook)

Converts from server side types (e.g. moment dates) to basic JS types, which is usually required when writing to the database.

# .unmarshall(hook)

Converts back to server side types (e.g. moment dates) from basic JS types, which is usually required when reading from the database.

# Query management

source (opens new window)

# .marshallQuery(hook)

Converts from client/server side types (e.g. strings or moment dates) to basic JS types, which is usually required when querying the database.

# .marshallComparisonQuery(hook)

Converts from client/server side comparison types (e.g. numbers) to basic JS types, which is usually required when querying the database. Applies to $lt, $lte, $gt and $gte operators.

# .marshallSpatialQuery(hook)

Converts from client/server side spatial types (e.g. coordinates or numbers) to basic JS types, which is usually required when querying the database. Applies to MongoDB geospatial operators (opens new window).

# .processForecastTime(hook)

Find the nearest forecast date/time corresponding to a requested date/time or date/time range.

# .processData(hook)

Discard or retrieve forecast data when required depending on the query parameters.

# Logging

core source (opens new window), client source (opens new window)

# .log(hook)

  • Log error for each hook in error with error log level.
  • Log information for each hook ran with verbose (respectively debug for client) log level.
  • Log detailed information for each hook ran with debug (respectively trace for client) log level.

# Events

source (opens new window)

# .emit(hook)

Emit an event named {hook_type}Hook (e.g. beforeHook or afterHook) for each hook ran, the payload of the event being the hook object.

# By type