Skip to main content

Lifecycle and Hooks

Lifecycle in Frourio

Both frourio and frourio-express provide Hooks that take a form similar to fastify.

The overall lifecycle is shown in the figure below, and hooks such as onRequest, preParsing, preValidation, and preHandler can be defined.

Looking for docs on how to define hooks?

The definition of Hooks can be found on the Routing page. See the following links for a reference on defineController() and defineHooks().

Object ServerHooks

  [(Hooks Name)]: HooksHandler or HooksHandler[],

An object whose keys are the same as the names of hooks and whose values are HooksHandler or HooksHandler[].

Available names of hooks:

  • onRequest
  • preParsing
  • preValidation
  • preHandler

Function HooksHandler

Argument Type

done is the function to continue with the lifecycle.


The done callback is not available when using async/await or returning a Promise. If you do invoke a done callback in this situation unexpected behavior may occur, e.g. duplicate invocation of handlers.

ref. Hooks - Fastify