Home / Function/ checkVersion() — fastify Function Reference

checkVersion() — fastify Function Reference

Architecture documentation for the checkVersion() function in plugin-utils.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  68d95492_715f_9e40_59e9_7c7d39a78c38["checkVersion()"]
  7351467e_fa74_55c1_e257_0dfcb434a1e3["plugin-utils.js"]
  68d95492_715f_9e40_59e9_7c7d39a78c38 -->|defined in| 7351467e_fa74_55c1_e257_0dfcb434a1e3
  5b05b925_857e_fbd2_7a8e_eeb788504648["getMeta()"]
  68d95492_715f_9e40_59e9_7c7d39a78c38 -->|calls| 5b05b925_857e_fbd2_7a8e_eeb788504648
  style 68d95492_715f_9e40_59e9_7c7d39a78c38 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/plugin-utils.js lines 109–129

function checkVersion (fn) {
  const meta = getMeta(fn)
  if (meta?.fastify == null) return

  const requiredVersion = meta.fastify

  const fastifyRc = rcRegex.test(this.version)
  if (fastifyRc === true && semver.gt(this.version, semver.coerce(requiredVersion)) === true) {
    // A Fastify release candidate phase is taking place. In order to reduce
    // the effort needed to test plugins with the RC, we allow plugins targeting
    // the prior Fastify release to be loaded.
    return
  }
  if (requiredVersion && semver.satisfies(this.version, requiredVersion, { includePrerelease: fastifyRc }) === false) {
    // We are not in a release candidate phase. Thus, we must honor the semver
    // ranges defined by the plugin's metadata. Which is to say, if the plugin
    // expects an older version of Fastify than the _current_ version, we will
    // throw an error.
    throw new FST_ERR_PLUGIN_VERSION_MISMATCH(meta.name, requiredVersion, this.version)
  }
}

Domain

Subdomains

Defined In

Calls

Frequently Asked Questions

What does checkVersion() do?
checkVersion() is a function in the fastify codebase, defined in lib/plugin-utils.js.
Where is checkVersion() defined?
checkVersion() is defined in lib/plugin-utils.js at line 109.
What does checkVersion() call?
checkVersion() calls 1 function(s): getMeta.

Analyze Your Own Codebase

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

Try Supermodel Free