Home / Function/ preParsingHookRunner() — fastify Function Reference

preParsingHookRunner() — fastify Function Reference

Architecture documentation for the preParsingHookRunner() function in hooks.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  b43f2f71_9af0_da6f_2d5c_3f193d97089c["preParsingHookRunner()"]
  57bfad3b_e85a_1ebf_2702_a13bb6484083["hooks.js"]
  b43f2f71_9af0_da6f_2d5c_3f193d97089c -->|defined in| 57bfad3b_e85a_1ebf_2702_a13bb6484083
  style b43f2f71_9af0_da6f_2d5c_3f193d97089c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/hooks.js lines 325–368

function preParsingHookRunner (functions, request, reply, cb) {
  let i = 0

  function next (err, newPayload) {
    if (reply.sent) {
      return
    }

    if (newPayload !== undefined) {
      request[kRequestPayloadStream] = newPayload
    }

    if (err || i === functions.length) {
      cb(err, request, reply)
      return
    }

    let result
    try {
      result = functions[i++](request, reply, request[kRequestPayloadStream], next)
    } catch (error) {
      cb(error, request, reply)
      return
    }

    if (result && typeof result.then === 'function') {
      result.then(handleResolve, handleReject)
    }
  }

  function handleResolve (newPayload) {
    next(null, newPayload)
  }

  function handleReject (err) {
    if (!err) {
      err = new FST_ERR_SEND_UNDEFINED_ERR()
    }

    cb(err, request, reply)
  }

  next()
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does preParsingHookRunner() do?
preParsingHookRunner() is a function in the fastify codebase, defined in lib/hooks.js.
Where is preParsingHookRunner() defined?
preParsingHookRunner() is defined in lib/hooks.js at line 325.

Analyze Your Own Codebase

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

Try Supermodel Free