HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/LC/node_modules/fastify-plugin/plugin.js
'use strict'

const getPluginName = require('./lib/getPluginName')
const toCamelCase = require('./lib/toCamelCase')

let count = 0

function plugin (fn, options = {}) {
  let autoName = false

  if (typeof fn.default !== 'undefined') {
    // Support for 'export default' behaviour in transpiled ECMAScript module
    fn = fn.default
  }

  if (typeof fn !== 'function') {
    throw new TypeError(
      `fastify-plugin expects a function, instead got a '${typeof fn}'`
    )
  }

  if (typeof options === 'string') {
    options = {
      fastify: options
    }
  }

  if (
    typeof options !== 'object' ||
    Array.isArray(options) ||
    options === null
  ) {
    throw new TypeError('The options object should be an object')
  }

  if (options.fastify !== undefined && typeof options.fastify !== 'string') {
    throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`)
  }

  if (!options.name) {
    autoName = true
    options.name = getPluginName(fn) + '-auto-' + count++
  }

  fn[Symbol.for('skip-override')] = options.encapsulate !== true
  fn[Symbol.for('fastify.display-name')] = options.name
  fn[Symbol.for('plugin-meta')] = options

  // Faux modules support
  if (!fn.default) {
    fn.default = fn
  }

  // TypeScript support for named imports
  // See https://github.com/fastify/fastify/issues/2404 for more details
  // The type definitions would have to be update to match this.
  const camelCase = toCamelCase(options.name)
  if (!autoName && !fn[camelCase]) {
    fn[camelCase] = fn
  }

  return fn
}

module.exports = plugin
module.exports.default = plugin
module.exports.fastifyPlugin = plugin