Home / File/ hooks.js — fastify Source File

hooks.js — fastify Source File

Architecture documentation for hooks.js, a javascript file in the fastify codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

const applicationHooks = [
  'onRoute',
  'onRegister',
  'onReady',
  'onListen',
  'preClose',
  'onClose'
]
const lifecycleHooks = [
  'onTimeout',
  'onRequest',
  'preParsing',
  'preValidation',
  'preSerialization',
  'preHandler',
  'onSend',
  'onResponse',
  'onError',
  'onRequestAbort'
]
const supportedHooks = lifecycleHooks.concat(applicationHooks)
const {
  FST_ERR_HOOK_INVALID_TYPE,
  FST_ERR_HOOK_INVALID_HANDLER,
  FST_ERR_SEND_UNDEFINED_ERR,
  FST_ERR_HOOK_TIMEOUT,
  FST_ERR_HOOK_NOT_SUPPORTED,
  AVVIO_ERRORS_MAP,
  appendStackTrace
} = require('./errors')

const {
  kChildren,
  kHooks,
  kRequestPayloadStream
} = require('./symbols')

function Hooks () {
  this.onRequest = []
  this.preParsing = []
  this.preValidation = []
  this.preSerialization = []
  this.preHandler = []
  this.onResponse = []
  this.onSend = []
  this.onError = []
  this.onRoute = []
  this.onRegister = []
  this.onReady = []
  this.onListen = []
  this.onTimeout = []
  this.onRequestAbort = []
  this.preClose = []
}

Hooks.prototype = Object.create(null)

Hooks.prototype.validate = function (hook, fn) {
// ... (370 more lines)

Domain

Subdomains

Frequently Asked Questions

What does hooks.js do?
hooks.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
What functions are defined in hooks.js?
hooks.js defines 12 function(s): Hooks, add, buildHooks, hookIterator, hookRunnerApplication, hookRunnerGenerator, onListenHookRunner, onRequestAbortHookRunner, onResponseHookIterator, onSendHookRunner, and 2 more.
Where is hooks.js in the architecture?
hooks.js is located at lib/hooks.js (domain: CoreKernel, subdomain: LifecycleManager, directory: lib).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free