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/build/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
const Ajv = require('ajv')
const fs = require('fs')
const path = require('path')
const pack = require('ajv-pack')
const ajv = new Ajv({
sourceCode: true, // this option is required by ajv-pack
removeAdditional: true,
useDefaults: true,
coerceTypes: true
})
const defaultInitOptions = {
connectionTimeout: 0, // 0 sec
keepAliveTimeout: 5000, // 5 sec
maxRequestsPerSocket: 0, // no limit
requestTimeout: 0, // no limit
bodyLimit: 1024 * 1024, // 1 MiB
caseSensitive: true,
disableRequestLogging: false,
jsonShorthand: true,
ignoreTrailingSlash: false,
maxParamLength: 100,
onProtoPoisoning: 'error',
onConstructorPoisoning: 'error',
pluginTimeout: 10000,
requestIdHeader: 'request-id',
requestIdLogLabel: 'reqId',
http2SessionTimeout: 5000
}
function customRule0 (schemaParamValue, validatedParamValue, validationSchemaObject, currentDataPath, validatedParamObject, validatedParam) {
validatedParamObject[validatedParam] = schemaParamValue
return true
}
// We add a keyword that allow us to set default values
ajv.addKeyword('setDefaultValue', {
modifying: true,
validate: customRule0,
errors: false
})
const schema = {
type: 'object',
additionalProperties: false,
properties: {
connectionTimeout: { type: 'integer', default: defaultInitOptions.connectionTimeout },
keepAliveTimeout: { type: 'integer', default: defaultInitOptions.keepAliveTimeout },
maxRequestsPerSocket: { type: 'integer', default: defaultInitOptions.maxRequestsPerSocket, nullable: true },
requestTimeout: { type: 'integer', default: defaultInitOptions.requestTimeout },
bodyLimit: { type: 'integer', default: defaultInitOptions.bodyLimit },
caseSensitive: { type: 'boolean', default: defaultInitOptions.caseSensitive },
http2: { type: 'boolean' },
https: {
if: {
not: {
oneOf: [
{ type: 'boolean' },
{ type: 'null' },
{
type: 'object',
additionalProperties: false,
required: ['allowHTTP1'],
properties: {
allowHTTP1: { type: 'boolean' }
}
}
]
}
},
then: { setDefaultValue: true }
},
ignoreTrailingSlash: { type: 'boolean', default: defaultInitOptions.ignoreTrailingSlash },
disableRequestLogging: {
type: 'boolean',
default: false
},
jsonShorthand: { type: 'boolean', default: defaultInitOptions.jsonShorthand },
maxParamLength: { type: 'integer', default: defaultInitOptions.maxParamLength },
onProtoPoisoning: { type: 'string', default: defaultInitOptions.onProtoPoisoning },
onConstructorPoisoning: { type: 'string', default: defaultInitOptions.onConstructorPoisoning },
pluginTimeout: { type: 'integer', default: defaultInitOptions.pluginTimeout },
requestIdHeader: { type: 'string', default: defaultInitOptions.requestIdHeader },
requestIdLogLabel: { type: 'string', default: defaultInitOptions.requestIdLogLabel },
http2SessionTimeout: { type: 'integer', default: defaultInitOptions.http2SessionTimeout },
// deprecated style of passing the versioning constraint
versioning: {
type: 'object',
additionalProperties: true,
required: ['storage', 'deriveVersion'],
properties: {
storage: { },
deriveVersion: { }
}
},
constraints: {
type: 'object',
additionalProperties: {
type: 'object',
required: ['name', 'storage', 'validate', 'deriveConstraint'],
additionalProperties: true,
properties: {
name: { type: 'string' },
storage: { },
validate: { },
deriveConstraint: { }
}
}
}
}
}
const validate = ajv.compile(schema)
const moduleCode = `// This file is autogenerated by ${__filename.replace(__dirname, 'build')}, do not edit
/* istanbul ignore file */
// constant needed for customRule0 to work
const self = {}
${pack(ajv, validate)}
${customRule0.toString()}
module.exports.defaultInitOptions = ${JSON.stringify(defaultInitOptions)}
`
fs.writeFileSync(path.join(__dirname, '..', 'lib', 'configValidator.js'), moduleCode)
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0061 ]-- |