From 24135727343719dd5bd6112b27830f70124d87ac Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Sun, 29 Sep 2024 17:24:55 -0400 Subject: [PATCH 1/5] chore: setup borp reporter for switch to node test --- package.json | 3 +- test/same-shape.test.js | 10 +++---- test/test-reporter.mjs | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 test/test-reporter.mjs diff --git a/package.json b/package.json index 09a8f63ea3..6eb23023b9 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js", "test:typescript": "tsc test/types/import.ts --noEmit && tsd", "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse", - "unit": "tap", + "unit": "borp --coverage --check-coverage --lines 100 --reporter ./test/test-reporter.mjs", "unit:junit": "tap-mocha-reporter xunit < out.tap > test/junit-testresults.xml", "unit:report": "tap --coverage-report=html --coverage-report=cobertura | tee out.tap", "citgm": "tap --jobs=1 --timeout=120" @@ -163,6 +163,7 @@ "ajv-i18n": "^4.2.0", "ajv-merge-patch": "^5.0.1", "autocannon": "^7.15.0", + "borp": "^0.17.0", "branch-comparer": "^1.1.0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", diff --git a/test/same-shape.test.js b/test/same-shape.test.js index 3157c71eaf..f416271333 100644 --- a/test/same-shape.test.js +++ b/test/same-shape.test.js @@ -1,6 +1,6 @@ 'use strict' -const { test } = require('tap') +const { test } = require('node:test') const fastify = require('..') test('same shape on Request', async (t) => { @@ -21,7 +21,7 @@ test('same shape on Request', async (t) => { app.get('/', (req, reply) => { if (request) { - t.equal(%HaveSameMap(request, req), true) + t.assert.deepStrictEqual(request, req) } request = req @@ -51,7 +51,7 @@ test('same shape on Request when object', async (t) => { app.get('/', (req, reply) => { if (request) { - t.equal(%HaveSameMap(request, req), true) + t.assert.deepStrictEqual(request, req) } request = req @@ -81,7 +81,7 @@ test('same shape on Reply', async (t) => { app.get('/', (req, reply) => { if (_reply) { - t.equal(%HaveSameMap(_reply, reply), true) + t.assert.deepStrictEqual(_reply, reply) } _reply = reply @@ -111,7 +111,7 @@ test('same shape on Reply when object', async (t) => { app.get('/', (req, reply) => { if (_reply) { - t.equal(%HaveSameMap(_reply, reply), true) + t.assert.deepStrictEqual(_reply, reply) } _reply = reply diff --git a/test/test-reporter.mjs b/test/test-reporter.mjs new file mode 100644 index 0000000000..974fe5d17b --- /dev/null +++ b/test/test-reporter.mjs @@ -0,0 +1,66 @@ +function colorize (type, text) { + if (type === 'pass') { + const whiteText = `\x1b[30m${text}` + // Green background with black text + return `\x1b[42m${whiteText}\x1b[0m` + } + + if (type === 'fail') { + const blackText = `\x1b[37m${text}` + // Red background with white text + return `\x1b[41m${blackText}\x1b[0m` + } + + return text +} + +function formatDiagnosticStr (str) { + return str.replace(/^(\w+)(\s*\d*)/i, (_, firstWord, rest) => { + return firstWord.charAt(0).toUpperCase() + firstWord.slice(1).toLowerCase() + ':' + rest + }) +} + +async function * reporter (source) { + const failed = new Set() + const diagnostics = new Set() + diagnostics.add('\n\n') + + for await (const event of source) { + switch (event.type) { + case 'test:pass': { + yield `${colorize('pass', 'PASSED')}: ${event.data.file}\n` + break + } + + case 'test:fail': { + failed.add(event.data.file) + yield `${colorize('fail', 'FAILED')}: ${event.data.file}\n` + break + } + + case 'test:diagnostic': { + diagnostics.add(`${formatDiagnosticStr(event.data.message)}\n`) + break + } + + default: { + yield '' + } + } + } + + if (failed.size > 0) { + yield `\n\n${colorize('fail', 'Failed tests:')}\n` + for (const file of failed) { + yield `${file}\n` + } + } + + diagnostics.add('\n') + + for (const diagnostic of diagnostics) { + yield `${diagnostic}` + } +} + +export default reporter From 8c785e78d1c5509e1a4d7081eb1949933f8d7cb7 Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Wed, 2 Oct 2024 23:13:39 -0400 Subject: [PATCH 2/5] chore: update scripts and test-reporter --- package.json | 16 ++++++++-------- test/test-reporter.mjs | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 6eb23023b9..f0e26e41d1 100644 --- a/package.json +++ b/package.json @@ -10,24 +10,23 @@ "benchmark": "concurrently -k -s first \"node ./examples/benchmark/simple.js\" \"autocannon -c 100 -d 30 -p 10 localhost:3000/\"", "benchmark:parser": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -m POST localhost:3000/\"", "build:validation": "node build/build-error-serializer.js && node build/build-validation.js", - "coverage": "npm run unit -- --coverage-report=html", - "coverage:ci": "tap --coverage-report=html --coverage-report=lcov --allow-incomplete-coverage", - "coverage:ci-check-coverage": "tap replay", + "coverage": "borp --reporter test/test-reporter.mjs --coverage --check-coverage --lines 100", + "coverage:ci": "nyc --coverage-report=html --coverage-report=lcov borp --reporter test/test-reporter.mjs", + "coverage:ci-check-coverage": "borp --reporter ./test/test-reporter.mjs --coverage --check-coverage --lines 100", "lint": "npm run lint:eslint", "lint:fix": "eslint --fix", "lint:markdown": "markdownlint-cli2", "lint:eslint": "eslint", - "prepublishOnly": "cross-env PREPUBLISH=true tap --allow-incomplete-coverage test/build/**.test.js && npm run test:validator:integrity", + "prepublishOnly": "cross-env PREPUBLISH=true borp --reporter ./test/test-reporter.mjs && npm run test:validator:integrity", "test": "npm run lint && npm run unit && npm run test:typescript", "test:ci": "npm run unit -- --coverage-report=lcovonly && npm run test:typescript", "test:report": "npm run lint && npm run unit:report && npm run test:typescript", "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js", "test:typescript": "tsc test/types/import.ts --noEmit && tsd", "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse", - "unit": "borp --coverage --check-coverage --lines 100 --reporter ./test/test-reporter.mjs", - "unit:junit": "tap-mocha-reporter xunit < out.tap > test/junit-testresults.xml", - "unit:report": "tap --coverage-report=html --coverage-report=cobertura | tee out.tap", - "citgm": "tap --jobs=1 --timeout=120" + "unit": "borp --reporter=test/test-reporter.mjs", + "unit:report": "nyc --coverage-report=html --reporter=cobertura borp --reporter test/test-reporter.mjs", + "citgm": "borp --reporter ./test/test-reporter.mjs --concurrency=1" }, "repository": { "type": "git", @@ -179,6 +178,7 @@ "markdownlint-cli2": "^0.13.0", "neostandard": "^0.11.3", "node-forge": "^1.3.1", + "nyc": "^17.1.0", "proxyquire": "^2.1.3", "simple-get": "^4.0.1", "split2": "^4.2.0", diff --git a/test/test-reporter.mjs b/test/test-reporter.mjs index 974fe5d17b..bf7087ec81 100644 --- a/test/test-reporter.mjs +++ b/test/test-reporter.mjs @@ -1,14 +1,16 @@ function colorize (type, text) { if (type === 'pass') { - const whiteText = `\x1b[30m${text}` + const blackText = `\x1b[30m${text}` + const boldblackText = `\x1b[1m${blackText}` // Green background with black text - return `\x1b[42m${whiteText}\x1b[0m` + return `\x1b[42m${boldblackText}\x1b[0m` } if (type === 'fail') { - const blackText = `\x1b[37m${text}` + const whiteText = `\x1b[37m${text}` + const boldWhiteText = `\x1b[1m${whiteText}` // Red background with white text - return `\x1b[41m${blackText}\x1b[0m` + return `\x1b[41m${boldWhiteText}\x1b[0m` } return text @@ -23,18 +25,17 @@ function formatDiagnosticStr (str) { async function * reporter (source) { const failed = new Set() const diagnostics = new Set() - diagnostics.add('\n\n') for await (const event of source) { switch (event.type) { case 'test:pass': { - yield `${colorize('pass', 'PASSED')}: ${event.data.file}\n` + yield `${colorize('pass', 'PASSED')}: ${event.data.file || event.data.name}\n` break } case 'test:fail': { - failed.add(event.data.file) - yield `${colorize('fail', 'FAILED')}: ${event.data.file}\n` + failed.add(event.data.name || event.data.file) + yield `${colorize('fail', 'FAILED')}: ${event.data.file || event.data.name}\n` break } @@ -56,11 +57,12 @@ async function * reporter (source) { } } - diagnostics.add('\n') + yield '\n' for (const diagnostic of diagnostics) { yield `${diagnostic}` } + yield '\n' } export default reporter From 445f139088015045589056bb02c2cf5c2c6752ae Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Tue, 8 Oct 2024 09:43:14 -0400 Subject: [PATCH 3/5] update scripts --- lib/logger.js | 2 ++ package.json | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 75c2288e97..8643be6520 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,10 +1,12 @@ 'use strict' +/* c8 ignore start */ /** * Code imported from `pino-http` * Repo: https://github.com/pinojs/pino-http * License: MIT (https://raw.githubusercontent.com/pinojs/pino-http/master/LICENSE) */ +/* c8 ignore stop */ const nullLogger = require('abstract-logging') const pino = require('pino') diff --git a/package.json b/package.json index f0e26e41d1..ee09bc4d06 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "benchmark:parser": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -m POST localhost:3000/\"", "build:validation": "node build/build-error-serializer.js && node build/build-validation.js", "coverage": "borp --reporter test/test-reporter.mjs --coverage --check-coverage --lines 100", - "coverage:ci": "nyc --coverage-report=html --coverage-report=lcov borp --reporter test/test-reporter.mjs", + "coverage:ci": "nyc --coverage-report=html --coverage-report=lcov borp --reporter test/test-reporter.mjs --coverage --check-coverage", "coverage:ci-check-coverage": "borp --reporter ./test/test-reporter.mjs --coverage --check-coverage --lines 100", "lint": "npm run lint:eslint", "lint:fix": "eslint --fix", @@ -19,14 +19,14 @@ "lint:eslint": "eslint", "prepublishOnly": "cross-env PREPUBLISH=true borp --reporter ./test/test-reporter.mjs && npm run test:validator:integrity", "test": "npm run lint && npm run unit && npm run test:typescript", - "test:ci": "npm run unit -- --coverage-report=lcovonly && npm run test:typescript", + "test:ci": "npm run unit && npm run test:typescript", "test:report": "npm run lint && npm run unit:report && npm run test:typescript", "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js", "test:typescript": "tsc test/types/import.ts --noEmit && tsd", "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse", "unit": "borp --reporter=test/test-reporter.mjs", - "unit:report": "nyc --coverage-report=html --reporter=cobertura borp --reporter test/test-reporter.mjs", - "citgm": "borp --reporter ./test/test-reporter.mjs --concurrency=1" + "unit:report": "nyc --coverage-report=html --reporter=cobertura borp --reporter test/test-reporter.mjs --coverage --check-coverage", + "citgm": "borp --reporter ./test/test-reporter.mjs --coverage --check-coverage --concurrency=1" }, "repository": { "type": "git", From c17b4dd49ce766897b030567fa832f216473b898 Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Wed, 9 Oct 2024 13:22:19 -0400 Subject: [PATCH 4/5] fix --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ee09bc4d06..3213b8556e 100644 --- a/package.json +++ b/package.json @@ -10,23 +10,23 @@ "benchmark": "concurrently -k -s first \"node ./examples/benchmark/simple.js\" \"autocannon -c 100 -d 30 -p 10 localhost:3000/\"", "benchmark:parser": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -m POST localhost:3000/\"", "build:validation": "node build/build-error-serializer.js && node build/build-validation.js", - "coverage": "borp --reporter test/test-reporter.mjs --coverage --check-coverage --lines 100", - "coverage:ci": "nyc --coverage-report=html --coverage-report=lcov borp --reporter test/test-reporter.mjs --coverage --check-coverage", - "coverage:ci-check-coverage": "borp --reporter ./test/test-reporter.mjs --coverage --check-coverage --lines 100", + "coverage": "borp --reporter=./test/test-reporter.mjs --coverage --check-coverage --lines 100", + "coverage:ci": "nyc --coverage-report=html --coverage-report=lcov borp --reporter=./test/test-reporter.mjs --coverage --check-coverage", + "coverage:ci-check-coverage": "borp --reporter=./test/test-reporter.mjs --coverage --check-coverage --lines 100", "lint": "npm run lint:eslint", "lint:fix": "eslint --fix", "lint:markdown": "markdownlint-cli2", "lint:eslint": "eslint", - "prepublishOnly": "cross-env PREPUBLISH=true borp --reporter ./test/test-reporter.mjs && npm run test:validator:integrity", + "prepublishOnly": "cross-env PREPUBLISH=true borp --reporter=./test/test-reporter.mjs && npm run test:validator:integrity", "test": "npm run lint && npm run unit && npm run test:typescript", "test:ci": "npm run unit && npm run test:typescript", "test:report": "npm run lint && npm run unit:report && npm run test:typescript", "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js", "test:typescript": "tsc test/types/import.ts --noEmit && tsd", "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse", - "unit": "borp --reporter=test/test-reporter.mjs", - "unit:report": "nyc --coverage-report=html --reporter=cobertura borp --reporter test/test-reporter.mjs --coverage --check-coverage", - "citgm": "borp --reporter ./test/test-reporter.mjs --coverage --check-coverage --concurrency=1" + "unit": "borp --reporter=./test/test-reporter.mjs", + "unit:report": "nyc --coverage-report=html --reporter=cobertura borp --reporter=./test/test-reporter.mjs --coverage --check-coverage", + "citgm": "borp --reporter=./test/test-reporter.mjs --coverage --check-coverage --concurrency=1" }, "repository": { "type": "git", From 736fac63916c4cb975aaed961f53c4f28939afa7 Mon Sep 17 00:00:00 2001 From: "dan.castillo" Date: Wed, 9 Oct 2024 16:12:40 -0400 Subject: [PATCH 5/5] testing borp CI/CD on with fastify --- lib/configValidator.js | 2112 ++++++++++++++--------------- lib/error-serializer.js | 185 ++- package.json | 2 +- test/schema-serialization.test.js | 2 +- 4 files changed, 1104 insertions(+), 1197 deletions(-) diff --git a/lib/configValidator.js b/lib/configValidator.js index 2c1e8b1534..0be380f671 100644 --- a/lib/configValidator.js +++ b/lib/configValidator.js @@ -1,1104 +1,1020 @@ // This file is autogenerated by build/build-validation.js, do not edit /* c8 ignore start */ -"use strict"; -module.exports = validate10; -module.exports.default = validate10; -const schema11 = {"type":"object","additionalProperties":false,"properties":{"connectionTimeout":{"type":"integer","default":0},"keepAliveTimeout":{"type":"integer","default":72000},"forceCloseConnections":{"oneOf":[{"type":"string","pattern":"idle"},{"type":"boolean"}]},"maxRequestsPerSocket":{"type":"integer","default":0,"nullable":true},"requestTimeout":{"type":"integer","default":0},"bodyLimit":{"type":"integer","default":1048576},"caseSensitive":{"type":"boolean","default":true},"allowUnsafeRegex":{"type":"boolean","default":false},"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":false},"ignoreDuplicateSlashes":{"type":"boolean","default":false},"disableRequestLogging":{"type":"boolean","default":false},"maxParamLength":{"type":"integer","default":100},"onProtoPoisoning":{"type":"string","default":"error"},"onConstructorPoisoning":{"type":"string","default":"error"},"pluginTimeout":{"type":"integer","default":10000},"requestIdHeader":{"anyOf":[{"type":"boolean"},{"type":"string"}],"default":false},"requestIdLogLabel":{"type":"string","default":"reqId"},"http2SessionTimeout":{"type":"integer","default":72000},"exposeHeadRoutes":{"type":"boolean","default":true},"useSemicolonDelimiter":{"type":"boolean","default":false},"constraints":{"type":"object","additionalProperties":{"type":"object","required":["name","storage","validate","deriveConstraint"],"additionalProperties":true,"properties":{"name":{"type":"string"},"storage":{},"validate":{},"deriveConstraint":{}}}}}}; -const func2 = Object.prototype.hasOwnProperty; -const pattern0 = new RegExp("idle", "u"); +'use strict' +module.exports = validate10 +module.exports.default = validate10 +const schema11 = { type: 'object', additionalProperties: false, properties: { connectionTimeout: { type: 'integer', default: 0 }, keepAliveTimeout: { type: 'integer', default: 72000 }, forceCloseConnections: { oneOf: [{ type: 'string', pattern: 'idle' }, { type: 'boolean' }] }, maxRequestsPerSocket: { type: 'integer', default: 0, nullable: true }, requestTimeout: { type: 'integer', default: 0 }, bodyLimit: { type: 'integer', default: 1048576 }, caseSensitive: { type: 'boolean', default: true }, allowUnsafeRegex: { type: 'boolean', default: false }, 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: false }, ignoreDuplicateSlashes: { type: 'boolean', default: false }, disableRequestLogging: { type: 'boolean', default: false }, maxParamLength: { type: 'integer', default: 100 }, onProtoPoisoning: { type: 'string', default: 'error' }, onConstructorPoisoning: { type: 'string', default: 'error' }, pluginTimeout: { type: 'integer', default: 10000 }, requestIdHeader: { anyOf: [{ type: 'boolean' }, { type: 'string' }], default: false }, requestIdLogLabel: { type: 'string', default: 'reqId' }, http2SessionTimeout: { type: 'integer', default: 72000 }, exposeHeadRoutes: { type: 'boolean', default: true }, useSemicolonDelimiter: { type: 'boolean', default: false }, constraints: { type: 'object', additionalProperties: { type: 'object', required: ['name', 'storage', 'validate', 'deriveConstraint'], additionalProperties: true, properties: { name: { type: 'string' }, storage: {}, validate: {}, deriveConstraint: {} } } } } } +const func2 = Object.prototype.hasOwnProperty +const pattern0 = new RegExp('idle', 'u') -function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){ -let vErrors = null; -let errors = 0; -if(errors === 0){ -if(data && typeof data == "object" && !Array.isArray(data)){ -if(data.connectionTimeout === undefined){ -data.connectionTimeout = 0; +function validate10 (data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) { + let vErrors = null + let errors = 0 + if (errors === 0) { + if (data && typeof data === 'object' && !Array.isArray(data)) { + if (data.connectionTimeout === undefined) { + data.connectionTimeout = 0 + } + if (data.keepAliveTimeout === undefined) { + data.keepAliveTimeout = 72000 + } + if (data.maxRequestsPerSocket === undefined) { + data.maxRequestsPerSocket = 0 + } + if (data.requestTimeout === undefined) { + data.requestTimeout = 0 + } + if (data.bodyLimit === undefined) { + data.bodyLimit = 1048576 + } + if (data.caseSensitive === undefined) { + data.caseSensitive = true + } + if (data.allowUnsafeRegex === undefined) { + data.allowUnsafeRegex = false + } + if (data.ignoreTrailingSlash === undefined) { + data.ignoreTrailingSlash = false + } + if (data.ignoreDuplicateSlashes === undefined) { + data.ignoreDuplicateSlashes = false + } + if (data.disableRequestLogging === undefined) { + data.disableRequestLogging = false + } + if (data.maxParamLength === undefined) { + data.maxParamLength = 100 + } + if (data.onProtoPoisoning === undefined) { + data.onProtoPoisoning = 'error' + } + if (data.onConstructorPoisoning === undefined) { + data.onConstructorPoisoning = 'error' + } + if (data.pluginTimeout === undefined) { + data.pluginTimeout = 10000 + } + if (data.requestIdHeader === undefined) { + data.requestIdHeader = false + } + if (data.requestIdLogLabel === undefined) { + data.requestIdLogLabel = 'reqId' + } + if (data.http2SessionTimeout === undefined) { + data.http2SessionTimeout = 72000 + } + if (data.exposeHeadRoutes === undefined) { + data.exposeHeadRoutes = true + } + if (data.useSemicolonDelimiter === undefined) { + data.useSemicolonDelimiter = false + } + const _errs1 = errors + for (const key0 in data) { + if (!(func2.call(schema11.properties, key0))) { + delete data[key0] + } + } + if (_errs1 === errors) { + let data0 = data.connectionTimeout + const _errs2 = errors + if (!(((typeof data0 === 'number') && (!(data0 % 1) && !isNaN(data0))) && (isFinite(data0)))) { + const dataType0 = typeof data0 + let coerced0 + if (!(coerced0 !== undefined)) { + if (dataType0 === 'boolean' || data0 === null || + (dataType0 === 'string' && data0 && data0 == +data0 && !(data0 % 1))) { + coerced0 = +data0 + } else { + validate10.errors = [{ instancePath: instancePath + '/connectionTimeout', schemaPath: '#/properties/connectionTimeout/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced0 !== undefined) { + data0 = coerced0 + if (data !== undefined) { + data.connectionTimeout = coerced0 + } + } + } + var valid0 = _errs2 === errors + if (valid0) { + let data1 = data.keepAliveTimeout + const _errs4 = errors + if (!(((typeof data1 === 'number') && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))) { + const dataType1 = typeof data1 + let coerced1 + if (!(coerced1 !== undefined)) { + if (dataType1 === 'boolean' || data1 === null || + (dataType1 === 'string' && data1 && data1 == +data1 && !(data1 % 1))) { + coerced1 = +data1 + } else { + validate10.errors = [{ instancePath: instancePath + '/keepAliveTimeout', schemaPath: '#/properties/keepAliveTimeout/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced1 !== undefined) { + data1 = coerced1 + if (data !== undefined) { + data.keepAliveTimeout = coerced1 + } + } + } + var valid0 = _errs4 === errors + if (valid0) { + if (data.forceCloseConnections !== undefined) { + let data2 = data.forceCloseConnections + const _errs6 = errors + const _errs7 = errors + let valid1 = false + let passing0 = null + const _errs8 = errors + if (typeof data2 !== 'string') { + const dataType2 = typeof data2 + let coerced2 + if (!(coerced2 !== undefined)) { + if (dataType2 == 'number' || dataType2 == 'boolean') { + coerced2 = '' + data2 + } else if (data2 === null) { + coerced2 = '' + } else { + const err0 = { instancePath: instancePath + '/forceCloseConnections', schemaPath: '#/properties/forceCloseConnections/oneOf/0/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' } + if (vErrors === null) { + vErrors = [err0] + } else { + vErrors.push(err0) + } + errors++ + } + } + if (coerced2 !== undefined) { + data2 = coerced2 + if (data !== undefined) { + data.forceCloseConnections = coerced2 + } + } + } + if (errors === _errs8) { + if (typeof data2 === 'string') { + if (!pattern0.test(data2)) { + const err1 = { instancePath: instancePath + '/forceCloseConnections', schemaPath: '#/properties/forceCloseConnections/oneOf/0/pattern', keyword: 'pattern', params: { pattern: 'idle' }, message: 'must match pattern "' + 'idle' + '"' } + if (vErrors === null) { + vErrors = [err1] + } else { + vErrors.push(err1) + } + errors++ + } + } + } + var _valid0 = _errs8 === errors + if (_valid0) { + valid1 = true + passing0 = 0 + } + const _errs10 = errors + if (typeof data2 !== 'boolean') { + let coerced3 + if (!(coerced3 !== undefined)) { + if (data2 === 'false' || data2 === 0 || data2 === null) { + coerced3 = false + } else if (data2 === 'true' || data2 === 1) { + coerced3 = true + } else { + const err2 = { instancePath: instancePath + '/forceCloseConnections', schemaPath: '#/properties/forceCloseConnections/oneOf/1/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' } + if (vErrors === null) { + vErrors = [err2] + } else { + vErrors.push(err2) + } + errors++ + } + } + if (coerced3 !== undefined) { + data2 = coerced3 + if (data !== undefined) { + data.forceCloseConnections = coerced3 + } + } + } + var _valid0 = _errs10 === errors + if (_valid0 && valid1) { + valid1 = false + passing0 = [passing0, 1] + } else { + if (_valid0) { + valid1 = true + passing0 = 1 + } + } + if (!valid1) { + const err3 = { instancePath: instancePath + '/forceCloseConnections', schemaPath: '#/properties/forceCloseConnections/oneOf', keyword: 'oneOf', params: { passingSchemas: passing0 }, message: 'must match exactly one schema in oneOf' } + if (vErrors === null) { + vErrors = [err3] + } else { + vErrors.push(err3) + } + errors++ + validate10.errors = vErrors + return false + } else { + errors = _errs7 + if (vErrors !== null) { + if (_errs7) { + vErrors.length = _errs7 + } else { + vErrors = null + } + } + } + var valid0 = _errs6 === errors + } else { + var valid0 = true + } + if (valid0) { + let data3 = data.maxRequestsPerSocket + const _errs12 = errors + if ((!(((typeof data3 === 'number') && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))) && (data3 !== null)) { + const dataType4 = typeof data3 + let coerced4 + if (!(coerced4 !== undefined)) { + if (dataType4 === 'boolean' || data3 === null || + (dataType4 === 'string' && data3 && data3 == +data3 && !(data3 % 1))) { + coerced4 = +data3 + } else if (data3 === '' || data3 === 0 || data3 === false) { + coerced4 = null + } else { + validate10.errors = [{ instancePath: instancePath + '/maxRequestsPerSocket', schemaPath: '#/properties/maxRequestsPerSocket/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced4 !== undefined) { + data3 = coerced4 + if (data !== undefined) { + data.maxRequestsPerSocket = coerced4 + } + } + } + var valid0 = _errs12 === errors + if (valid0) { + let data4 = data.requestTimeout + const _errs15 = errors + if (!(((typeof data4 === 'number') && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))) { + const dataType5 = typeof data4 + let coerced5 + if (!(coerced5 !== undefined)) { + if (dataType5 === 'boolean' || data4 === null || + (dataType5 === 'string' && data4 && data4 == +data4 && !(data4 % 1))) { + coerced5 = +data4 + } else { + validate10.errors = [{ instancePath: instancePath + '/requestTimeout', schemaPath: '#/properties/requestTimeout/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced5 !== undefined) { + data4 = coerced5 + if (data !== undefined) { + data.requestTimeout = coerced5 + } + } + } + var valid0 = _errs15 === errors + if (valid0) { + let data5 = data.bodyLimit + const _errs17 = errors + if (!(((typeof data5 === 'number') && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))) { + const dataType6 = typeof data5 + let coerced6 + if (!(coerced6 !== undefined)) { + if (dataType6 === 'boolean' || data5 === null || + (dataType6 === 'string' && data5 && data5 == +data5 && !(data5 % 1))) { + coerced6 = +data5 + } else { + validate10.errors = [{ instancePath: instancePath + '/bodyLimit', schemaPath: '#/properties/bodyLimit/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced6 !== undefined) { + data5 = coerced6 + if (data !== undefined) { + data.bodyLimit = coerced6 + } + } + } + var valid0 = _errs17 === errors + if (valid0) { + let data6 = data.caseSensitive + const _errs19 = errors + if (typeof data6 !== 'boolean') { + let coerced7 + if (!(coerced7 !== undefined)) { + if (data6 === 'false' || data6 === 0 || data6 === null) { + coerced7 = false + } else if (data6 === 'true' || data6 === 1) { + coerced7 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/caseSensitive', schemaPath: '#/properties/caseSensitive/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced7 !== undefined) { + data6 = coerced7 + if (data !== undefined) { + data.caseSensitive = coerced7 + } + } + } + var valid0 = _errs19 === errors + if (valid0) { + let data7 = data.allowUnsafeRegex + const _errs21 = errors + if (typeof data7 !== 'boolean') { + let coerced8 + if (!(coerced8 !== undefined)) { + if (data7 === 'false' || data7 === 0 || data7 === null) { + coerced8 = false + } else if (data7 === 'true' || data7 === 1) { + coerced8 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/allowUnsafeRegex', schemaPath: '#/properties/allowUnsafeRegex/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced8 !== undefined) { + data7 = coerced8 + if (data !== undefined) { + data.allowUnsafeRegex = coerced8 + } + } + } + var valid0 = _errs21 === errors + if (valid0) { + if (data.http2 !== undefined) { + let data8 = data.http2 + const _errs23 = errors + if (typeof data8 !== 'boolean') { + let coerced9 + if (!(coerced9 !== undefined)) { + if (data8 === 'false' || data8 === 0 || data8 === null) { + coerced9 = false + } else if (data8 === 'true' || data8 === 1) { + coerced9 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/http2', schemaPath: '#/properties/http2/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced9 !== undefined) { + data8 = coerced9 + if (data !== undefined) { + data.http2 = coerced9 + } + } + } + var valid0 = _errs23 === errors + } else { + var valid0 = true + } + if (valid0) { + if (data.https !== undefined) { + let data9 = data.https + const _errs25 = errors + const _errs26 = errors + let valid2 = true + const _errs27 = errors + const _errs28 = errors + const _errs29 = errors + const _errs30 = errors + let valid4 = false + let passing1 = null + const _errs31 = errors + if (typeof data9 !== 'boolean') { + let coerced10 + if (!(coerced10 !== undefined)) { + if (data9 === 'false' || data9 === 0 || data9 === null) { + coerced10 = false + } else if (data9 === 'true' || data9 === 1) { + coerced10 = true + } else { + const err4 = {} + if (vErrors === null) { + vErrors = [err4] + } else { + vErrors.push(err4) + } + errors++ + } + } + if (coerced10 !== undefined) { + data9 = coerced10 + if (data !== undefined) { + data.https = coerced10 + } + } + } + var _valid2 = _errs31 === errors + if (_valid2) { + valid4 = true + passing1 = 0 + } + const _errs33 = errors + if (data9 !== null) { + let coerced11 + if (!(coerced11 !== undefined)) { + if (data9 === '' || data9 === 0 || data9 === false) { + coerced11 = null + } else { + const err5 = {} + if (vErrors === null) { + vErrors = [err5] + } else { + vErrors.push(err5) + } + errors++ + } + } + if (coerced11 !== undefined) { + data9 = coerced11 + if (data !== undefined) { + data.https = coerced11 + } + } + } + var _valid2 = _errs33 === errors + if (_valid2 && valid4) { + valid4 = false + passing1 = [passing1, 1] + } else { + if (_valid2) { + valid4 = true + passing1 = 1 + } + const _errs35 = errors + if (errors === _errs35) { + if (data9 && typeof data9 === 'object' && !Array.isArray(data9)) { + let missing0 + if ((data9.allowHTTP1 === undefined) && (missing0 = 'allowHTTP1')) { + const err6 = {} + if (vErrors === null) { + vErrors = [err6] + } else { + vErrors.push(err6) + } + errors++ + } else { + const _errs37 = errors + for (const key1 in data9) { + if (!(key1 === 'allowHTTP1')) { + delete data9[key1] + } + } + if (_errs37 === errors) { + if (data9.allowHTTP1 !== undefined) { + let data10 = data9.allowHTTP1 + if (typeof data10 !== 'boolean') { + let coerced12 + if (!(coerced12 !== undefined)) { + if (data10 === 'false' || data10 === 0 || data10 === null) { + coerced12 = false + } else if (data10 === 'true' || data10 === 1) { + coerced12 = true + } else { + const err7 = {} + if (vErrors === null) { + vErrors = [err7] + } else { + vErrors.push(err7) + } + errors++ + } + } + if (coerced12 !== undefined) { + data10 = coerced12 + if (data9 !== undefined) { + data9.allowHTTP1 = coerced12 + } + } + } + } + } + } + } else { + const err8 = {} + if (vErrors === null) { + vErrors = [err8] + } else { + vErrors.push(err8) + } + errors++ + } + } + var _valid2 = _errs35 === errors + if (_valid2 && valid4) { + valid4 = false + passing1 = [passing1, 2] + } else { + if (_valid2) { + valid4 = true + passing1 = 2 + } + } + } + if (!valid4) { + const err9 = {} + if (vErrors === null) { + vErrors = [err9] + } else { + vErrors.push(err9) + } + errors++ + } else { + errors = _errs30 + if (vErrors !== null) { + if (_errs30) { + vErrors.length = _errs30 + } else { + vErrors = null + } + } + } + const valid3 = _errs29 === errors + if (valid3) { + const err10 = {} + if (vErrors === null) { + vErrors = [err10] + } else { + vErrors.push(err10) + } + errors++ + } else { + errors = _errs28 + if (vErrors !== null) { + if (_errs28) { + vErrors.length = _errs28 + } else { + vErrors = null + } + } + } + var _valid1 = _errs27 === errors + errors = _errs26 + if (vErrors !== null) { + if (_errs26) { + vErrors.length = _errs26 + } else { + vErrors = null + } + } + if (_valid1) { + const _errs40 = errors + data.https = true + var _valid1 = _errs40 === errors + valid2 = _valid1 + } + if (!valid2) { + const err11 = { instancePath: instancePath + '/https', schemaPath: '#/properties/https/if', keyword: 'if', params: { failingKeyword: 'then' }, message: 'must match "then" schema' } + if (vErrors === null) { + vErrors = [err11] + } else { + vErrors.push(err11) + } + errors++ + validate10.errors = vErrors + return false + } + var valid0 = _errs25 === errors + } else { + var valid0 = true + } + if (valid0) { + let data11 = data.ignoreTrailingSlash + const _errs41 = errors + if (typeof data11 !== 'boolean') { + let coerced13 + if (!(coerced13 !== undefined)) { + if (data11 === 'false' || data11 === 0 || data11 === null) { + coerced13 = false + } else if (data11 === 'true' || data11 === 1) { + coerced13 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/ignoreTrailingSlash', schemaPath: '#/properties/ignoreTrailingSlash/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced13 !== undefined) { + data11 = coerced13 + if (data !== undefined) { + data.ignoreTrailingSlash = coerced13 + } + } + } + var valid0 = _errs41 === errors + if (valid0) { + let data12 = data.ignoreDuplicateSlashes + const _errs43 = errors + if (typeof data12 !== 'boolean') { + let coerced14 + if (!(coerced14 !== undefined)) { + if (data12 === 'false' || data12 === 0 || data12 === null) { + coerced14 = false + } else if (data12 === 'true' || data12 === 1) { + coerced14 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/ignoreDuplicateSlashes', schemaPath: '#/properties/ignoreDuplicateSlashes/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced14 !== undefined) { + data12 = coerced14 + if (data !== undefined) { + data.ignoreDuplicateSlashes = coerced14 + } + } + } + var valid0 = _errs43 === errors + if (valid0) { + let data13 = data.disableRequestLogging + const _errs45 = errors + if (typeof data13 !== 'boolean') { + let coerced15 + if (!(coerced15 !== undefined)) { + if (data13 === 'false' || data13 === 0 || data13 === null) { + coerced15 = false + } else if (data13 === 'true' || data13 === 1) { + coerced15 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/disableRequestLogging', schemaPath: '#/properties/disableRequestLogging/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced15 !== undefined) { + data13 = coerced15 + if (data !== undefined) { + data.disableRequestLogging = coerced15 + } + } + } + var valid0 = _errs45 === errors + if (valid0) { + let data14 = data.maxParamLength + const _errs47 = errors + if (!(((typeof data14 === 'number') && (!(data14 % 1) && !isNaN(data14))) && (isFinite(data14)))) { + const dataType16 = typeof data14 + let coerced16 + if (!(coerced16 !== undefined)) { + if (dataType16 === 'boolean' || data14 === null || + (dataType16 === 'string' && data14 && data14 == +data14 && !(data14 % 1))) { + coerced16 = +data14 + } else { + validate10.errors = [{ instancePath: instancePath + '/maxParamLength', schemaPath: '#/properties/maxParamLength/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced16 !== undefined) { + data14 = coerced16 + if (data !== undefined) { + data.maxParamLength = coerced16 + } + } + } + var valid0 = _errs47 === errors + if (valid0) { + let data15 = data.onProtoPoisoning + const _errs49 = errors + if (typeof data15 !== 'string') { + const dataType17 = typeof data15 + let coerced17 + if (!(coerced17 !== undefined)) { + if (dataType17 == 'number' || dataType17 == 'boolean') { + coerced17 = '' + data15 + } else if (data15 === null) { + coerced17 = '' + } else { + validate10.errors = [{ instancePath: instancePath + '/onProtoPoisoning', schemaPath: '#/properties/onProtoPoisoning/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' }] + return false + } + } + if (coerced17 !== undefined) { + data15 = coerced17 + if (data !== undefined) { + data.onProtoPoisoning = coerced17 + } + } + } + var valid0 = _errs49 === errors + if (valid0) { + let data16 = data.onConstructorPoisoning + const _errs51 = errors + if (typeof data16 !== 'string') { + const dataType18 = typeof data16 + let coerced18 + if (!(coerced18 !== undefined)) { + if (dataType18 == 'number' || dataType18 == 'boolean') { + coerced18 = '' + data16 + } else if (data16 === null) { + coerced18 = '' + } else { + validate10.errors = [{ instancePath: instancePath + '/onConstructorPoisoning', schemaPath: '#/properties/onConstructorPoisoning/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' }] + return false + } + } + if (coerced18 !== undefined) { + data16 = coerced18 + if (data !== undefined) { + data.onConstructorPoisoning = coerced18 + } + } + } + var valid0 = _errs51 === errors + if (valid0) { + let data17 = data.pluginTimeout + const _errs53 = errors + if (!(((typeof data17 === 'number') && (!(data17 % 1) && !isNaN(data17))) && (isFinite(data17)))) { + const dataType19 = typeof data17 + let coerced19 + if (!(coerced19 !== undefined)) { + if (dataType19 === 'boolean' || data17 === null || + (dataType19 === 'string' && data17 && data17 == +data17 && !(data17 % 1))) { + coerced19 = +data17 + } else { + validate10.errors = [{ instancePath: instancePath + '/pluginTimeout', schemaPath: '#/properties/pluginTimeout/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced19 !== undefined) { + data17 = coerced19 + if (data !== undefined) { + data.pluginTimeout = coerced19 + } + } + } + var valid0 = _errs53 === errors + if (valid0) { + let data18 = data.requestIdHeader + const _errs55 = errors + const _errs56 = errors + let valid6 = false + const _errs57 = errors + if (typeof data18 !== 'boolean') { + let coerced20 + if (!(coerced20 !== undefined)) { + if (data18 === 'false' || data18 === 0 || data18 === null) { + coerced20 = false + } else if (data18 === 'true' || data18 === 1) { + coerced20 = true + } else { + const err12 = { instancePath: instancePath + '/requestIdHeader', schemaPath: '#/properties/requestIdHeader/anyOf/0/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' } + if (vErrors === null) { + vErrors = [err12] + } else { + vErrors.push(err12) + } + errors++ + } + } + if (coerced20 !== undefined) { + data18 = coerced20 + if (data !== undefined) { + data.requestIdHeader = coerced20 + } + } + } + var _valid3 = _errs57 === errors + valid6 = valid6 || _valid3 + if (!valid6) { + const _errs59 = errors + if (typeof data18 !== 'string') { + const dataType21 = typeof data18 + let coerced21 + if (!(coerced21 !== undefined)) { + if (dataType21 == 'number' || dataType21 == 'boolean') { + coerced21 = '' + data18 + } else if (data18 === null) { + coerced21 = '' + } else { + const err13 = { instancePath: instancePath + '/requestIdHeader', schemaPath: '#/properties/requestIdHeader/anyOf/1/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' } + if (vErrors === null) { + vErrors = [err13] + } else { + vErrors.push(err13) + } + errors++ + } + } + if (coerced21 !== undefined) { + data18 = coerced21 + if (data !== undefined) { + data.requestIdHeader = coerced21 + } + } + } + var _valid3 = _errs59 === errors + valid6 = valid6 || _valid3 + } + if (!valid6) { + const err14 = { instancePath: instancePath + '/requestIdHeader', schemaPath: '#/properties/requestIdHeader/anyOf', keyword: 'anyOf', params: {}, message: 'must match a schema in anyOf' } + if (vErrors === null) { + vErrors = [err14] + } else { + vErrors.push(err14) + } + errors++ + validate10.errors = vErrors + return false + } else { + errors = _errs56 + if (vErrors !== null) { + if (_errs56) { + vErrors.length = _errs56 + } else { + vErrors = null + } + } + } + var valid0 = _errs55 === errors + if (valid0) { + let data19 = data.requestIdLogLabel + const _errs61 = errors + if (typeof data19 !== 'string') { + const dataType22 = typeof data19 + let coerced22 + if (!(coerced22 !== undefined)) { + if (dataType22 == 'number' || dataType22 == 'boolean') { + coerced22 = '' + data19 + } else if (data19 === null) { + coerced22 = '' + } else { + validate10.errors = [{ instancePath: instancePath + '/requestIdLogLabel', schemaPath: '#/properties/requestIdLogLabel/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' }] + return false + } + } + if (coerced22 !== undefined) { + data19 = coerced22 + if (data !== undefined) { + data.requestIdLogLabel = coerced22 + } + } + } + var valid0 = _errs61 === errors + if (valid0) { + let data20 = data.http2SessionTimeout + const _errs63 = errors + if (!(((typeof data20 === 'number') && (!(data20 % 1) && !isNaN(data20))) && (isFinite(data20)))) { + const dataType23 = typeof data20 + let coerced23 + if (!(coerced23 !== undefined)) { + if (dataType23 === 'boolean' || data20 === null || + (dataType23 === 'string' && data20 && data20 == +data20 && !(data20 % 1))) { + coerced23 = +data20 + } else { + validate10.errors = [{ instancePath: instancePath + '/http2SessionTimeout', schemaPath: '#/properties/http2SessionTimeout/type', keyword: 'type', params: { type: 'integer' }, message: 'must be integer' }] + return false + } + } + if (coerced23 !== undefined) { + data20 = coerced23 + if (data !== undefined) { + data.http2SessionTimeout = coerced23 + } + } + } + var valid0 = _errs63 === errors + if (valid0) { + let data21 = data.exposeHeadRoutes + const _errs65 = errors + if (typeof data21 !== 'boolean') { + let coerced24 + if (!(coerced24 !== undefined)) { + if (data21 === 'false' || data21 === 0 || data21 === null) { + coerced24 = false + } else if (data21 === 'true' || data21 === 1) { + coerced24 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/exposeHeadRoutes', schemaPath: '#/properties/exposeHeadRoutes/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced24 !== undefined) { + data21 = coerced24 + if (data !== undefined) { + data.exposeHeadRoutes = coerced24 + } + } + } + var valid0 = _errs65 === errors + if (valid0) { + let data22 = data.useSemicolonDelimiter + const _errs67 = errors + if (typeof data22 !== 'boolean') { + let coerced25 + if (!(coerced25 !== undefined)) { + if (data22 === 'false' || data22 === 0 || data22 === null) { + coerced25 = false + } else if (data22 === 'true' || data22 === 1) { + coerced25 = true + } else { + validate10.errors = [{ instancePath: instancePath + '/useSemicolonDelimiter', schemaPath: '#/properties/useSemicolonDelimiter/type', keyword: 'type', params: { type: 'boolean' }, message: 'must be boolean' }] + return false + } + } + if (coerced25 !== undefined) { + data22 = coerced25 + if (data !== undefined) { + data.useSemicolonDelimiter = coerced25 + } + } + } + var valid0 = _errs67 === errors + if (valid0) { + if (data.constraints !== undefined) { + const data23 = data.constraints + const _errs69 = errors + if (errors === _errs69) { + if (data23 && typeof data23 === 'object' && !Array.isArray(data23)) { + for (const key2 in data23) { + const data24 = data23[key2] + const _errs72 = errors + if (errors === _errs72) { + if (data24 && typeof data24 === 'object' && !Array.isArray(data24)) { + let missing1 + if (((((data24.name === undefined) && (missing1 = 'name')) || ((data24.storage === undefined) && (missing1 = 'storage'))) || ((data24.validate === undefined) && (missing1 = 'validate'))) || ((data24.deriveConstraint === undefined) && (missing1 = 'deriveConstraint'))) { + validate10.errors = [{ instancePath: instancePath + '/constraints/' + key2.replace(/~/g, '~0').replace(/\//g, '~1'), schemaPath: '#/properties/constraints/additionalProperties/required', keyword: 'required', params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }] + return false + } else { + if (data24.name !== undefined) { + let data25 = data24.name + if (typeof data25 !== 'string') { + const dataType26 = typeof data25 + let coerced26 + if (!(coerced26 !== undefined)) { + if (dataType26 == 'number' || dataType26 == 'boolean') { + coerced26 = '' + data25 + } else if (data25 === null) { + coerced26 = '' + } else { + validate10.errors = [{ instancePath: instancePath + '/constraints/' + key2.replace(/~/g, '~0').replace(/\//g, '~1') + '/name', schemaPath: '#/properties/constraints/additionalProperties/properties/name/type', keyword: 'type', params: { type: 'string' }, message: 'must be string' }] + return false + } + } + if (coerced26 !== undefined) { + data25 = coerced26 + if (data24 !== undefined) { + data24.name = coerced26 + } + } + } + } + } + } else { + validate10.errors = [{ instancePath: instancePath + '/constraints/' + key2.replace(/~/g, '~0').replace(/\//g, '~1'), schemaPath: '#/properties/constraints/additionalProperties/type', keyword: 'type', params: { type: 'object' }, message: 'must be object' }] + return false + } + } + const valid7 = _errs72 === errors + if (!valid7) { + break + } + } + } else { + validate10.errors = [{ instancePath: instancePath + '/constraints', schemaPath: '#/properties/constraints/type', keyword: 'type', params: { type: 'object' }, message: 'must be object' }] + return false + } + } + var valid0 = _errs69 === errors + } else { + var valid0 = true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } else { + validate10.errors = [{ instancePath, schemaPath: '#/type', keyword: 'type', params: { type: 'object' }, message: 'must be object' }] + return false + } + } + validate10.errors = vErrors + return errors === 0 } -if(data.keepAliveTimeout === undefined){ -data.keepAliveTimeout = 72000; -} -if(data.maxRequestsPerSocket === undefined){ -data.maxRequestsPerSocket = 0; -} -if(data.requestTimeout === undefined){ -data.requestTimeout = 0; -} -if(data.bodyLimit === undefined){ -data.bodyLimit = 1048576; -} -if(data.caseSensitive === undefined){ -data.caseSensitive = true; -} -if(data.allowUnsafeRegex === undefined){ -data.allowUnsafeRegex = false; -} -if(data.ignoreTrailingSlash === undefined){ -data.ignoreTrailingSlash = false; -} -if(data.ignoreDuplicateSlashes === undefined){ -data.ignoreDuplicateSlashes = false; -} -if(data.disableRequestLogging === undefined){ -data.disableRequestLogging = false; -} -if(data.maxParamLength === undefined){ -data.maxParamLength = 100; -} -if(data.onProtoPoisoning === undefined){ -data.onProtoPoisoning = "error"; -} -if(data.onConstructorPoisoning === undefined){ -data.onConstructorPoisoning = "error"; -} -if(data.pluginTimeout === undefined){ -data.pluginTimeout = 10000; -} -if(data.requestIdHeader === undefined){ -data.requestIdHeader = false; -} -if(data.requestIdLogLabel === undefined){ -data.requestIdLogLabel = "reqId"; -} -if(data.http2SessionTimeout === undefined){ -data.http2SessionTimeout = 72000; -} -if(data.exposeHeadRoutes === undefined){ -data.exposeHeadRoutes = true; -} -if(data.useSemicolonDelimiter === undefined){ -data.useSemicolonDelimiter = false; -} -const _errs1 = errors; -for(const key0 in data){ -if(!(func2.call(schema11.properties, key0))){ -delete data[key0]; -} -} -if(_errs1 === errors){ -let data0 = data.connectionTimeout; -const _errs2 = errors; -if(!(((typeof data0 == "number") && (!(data0 % 1) && !isNaN(data0))) && (isFinite(data0)))){ -let dataType0 = typeof data0; -let coerced0 = undefined; -if(!(coerced0 !== undefined)){ -if(dataType0 === "boolean" || data0 === null - || (dataType0 === "string" && data0 && data0 == +data0 && !(data0 % 1))){ -coerced0 = +data0; -} -else { -validate10.errors = [{instancePath:instancePath+"/connectionTimeout",schemaPath:"#/properties/connectionTimeout/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced0 !== undefined){ -data0 = coerced0; -if(data !== undefined){ -data["connectionTimeout"] = coerced0; -} -} -} -var valid0 = _errs2 === errors; -if(valid0){ -let data1 = data.keepAliveTimeout; -const _errs4 = errors; -if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){ -let dataType1 = typeof data1; -let coerced1 = undefined; -if(!(coerced1 !== undefined)){ -if(dataType1 === "boolean" || data1 === null - || (dataType1 === "string" && data1 && data1 == +data1 && !(data1 % 1))){ -coerced1 = +data1; -} -else { -validate10.errors = [{instancePath:instancePath+"/keepAliveTimeout",schemaPath:"#/properties/keepAliveTimeout/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced1 !== undefined){ -data1 = coerced1; -if(data !== undefined){ -data["keepAliveTimeout"] = coerced1; -} -} -} -var valid0 = _errs4 === errors; -if(valid0){ -if(data.forceCloseConnections !== undefined){ -let data2 = data.forceCloseConnections; -const _errs6 = errors; -const _errs7 = errors; -let valid1 = false; -let passing0 = null; -const _errs8 = errors; -if(typeof data2 !== "string"){ -let dataType2 = typeof data2; -let coerced2 = undefined; -if(!(coerced2 !== undefined)){ -if(dataType2 == "number" || dataType2 == "boolean"){ -coerced2 = "" + data2; -} -else if(data2 === null){ -coerced2 = ""; -} -else { -const err0 = {instancePath:instancePath+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"}; -if(vErrors === null){ -vErrors = [err0]; -} -else { -vErrors.push(err0); -} -errors++; -} -} -if(coerced2 !== undefined){ -data2 = coerced2; -if(data !== undefined){ -data["forceCloseConnections"] = coerced2; -} -} -} -if(errors === _errs8){ -if(typeof data2 === "string"){ -if(!pattern0.test(data2)){ -const err1 = {instancePath:instancePath+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/pattern",keyword:"pattern",params:{pattern: "idle"},message:"must match pattern \""+"idle"+"\""}; -if(vErrors === null){ -vErrors = [err1]; -} -else { -vErrors.push(err1); -} -errors++; -} -} -} -var _valid0 = _errs8 === errors; -if(_valid0){ -valid1 = true; -passing0 = 0; -} -const _errs10 = errors; -if(typeof data2 !== "boolean"){ -let coerced3 = undefined; -if(!(coerced3 !== undefined)){ -if(data2 === "false" || data2 === 0 || data2 === null){ -coerced3 = false; -} -else if(data2 === "true" || data2 === 1){ -coerced3 = true; -} -else { -const err2 = {instancePath:instancePath+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/1/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}; -if(vErrors === null){ -vErrors = [err2]; -} -else { -vErrors.push(err2); -} -errors++; -} -} -if(coerced3 !== undefined){ -data2 = coerced3; -if(data !== undefined){ -data["forceCloseConnections"] = coerced3; -} -} -} -var _valid0 = _errs10 === errors; -if(_valid0 && valid1){ -valid1 = false; -passing0 = [passing0, 1]; -} -else { -if(_valid0){ -valid1 = true; -passing0 = 1; -} -} -if(!valid1){ -const err3 = {instancePath:instancePath+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"}; -if(vErrors === null){ -vErrors = [err3]; -} -else { -vErrors.push(err3); -} -errors++; -validate10.errors = vErrors; -return false; -} -else { -errors = _errs7; -if(vErrors !== null){ -if(_errs7){ -vErrors.length = _errs7; -} -else { -vErrors = null; -} -} -} -var valid0 = _errs6 === errors; -} -else { -var valid0 = true; -} -if(valid0){ -let data3 = data.maxRequestsPerSocket; -const _errs12 = errors; -if((!(((typeof data3 == "number") && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))) && (data3 !== null)){ -let dataType4 = typeof data3; -let coerced4 = undefined; -if(!(coerced4 !== undefined)){ -if(dataType4 === "boolean" || data3 === null - || (dataType4 === "string" && data3 && data3 == +data3 && !(data3 % 1))){ -coerced4 = +data3; -} -else if(data3 === "" || data3 === 0 || data3 === false){ -coerced4 = null; -} -else { -validate10.errors = [{instancePath:instancePath+"/maxRequestsPerSocket",schemaPath:"#/properties/maxRequestsPerSocket/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced4 !== undefined){ -data3 = coerced4; -if(data !== undefined){ -data["maxRequestsPerSocket"] = coerced4; -} -} -} -var valid0 = _errs12 === errors; -if(valid0){ -let data4 = data.requestTimeout; -const _errs15 = errors; -if(!(((typeof data4 == "number") && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))){ -let dataType5 = typeof data4; -let coerced5 = undefined; -if(!(coerced5 !== undefined)){ -if(dataType5 === "boolean" || data4 === null - || (dataType5 === "string" && data4 && data4 == +data4 && !(data4 % 1))){ -coerced5 = +data4; -} -else { -validate10.errors = [{instancePath:instancePath+"/requestTimeout",schemaPath:"#/properties/requestTimeout/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced5 !== undefined){ -data4 = coerced5; -if(data !== undefined){ -data["requestTimeout"] = coerced5; -} -} -} -var valid0 = _errs15 === errors; -if(valid0){ -let data5 = data.bodyLimit; -const _errs17 = errors; -if(!(((typeof data5 == "number") && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))){ -let dataType6 = typeof data5; -let coerced6 = undefined; -if(!(coerced6 !== undefined)){ -if(dataType6 === "boolean" || data5 === null - || (dataType6 === "string" && data5 && data5 == +data5 && !(data5 % 1))){ -coerced6 = +data5; -} -else { -validate10.errors = [{instancePath:instancePath+"/bodyLimit",schemaPath:"#/properties/bodyLimit/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced6 !== undefined){ -data5 = coerced6; -if(data !== undefined){ -data["bodyLimit"] = coerced6; -} -} -} -var valid0 = _errs17 === errors; -if(valid0){ -let data6 = data.caseSensitive; -const _errs19 = errors; -if(typeof data6 !== "boolean"){ -let coerced7 = undefined; -if(!(coerced7 !== undefined)){ -if(data6 === "false" || data6 === 0 || data6 === null){ -coerced7 = false; -} -else if(data6 === "true" || data6 === 1){ -coerced7 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/caseSensitive",schemaPath:"#/properties/caseSensitive/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced7 !== undefined){ -data6 = coerced7; -if(data !== undefined){ -data["caseSensitive"] = coerced7; -} -} -} -var valid0 = _errs19 === errors; -if(valid0){ -let data7 = data.allowUnsafeRegex; -const _errs21 = errors; -if(typeof data7 !== "boolean"){ -let coerced8 = undefined; -if(!(coerced8 !== undefined)){ -if(data7 === "false" || data7 === 0 || data7 === null){ -coerced8 = false; -} -else if(data7 === "true" || data7 === 1){ -coerced8 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/allowUnsafeRegex",schemaPath:"#/properties/allowUnsafeRegex/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced8 !== undefined){ -data7 = coerced8; -if(data !== undefined){ -data["allowUnsafeRegex"] = coerced8; -} -} -} -var valid0 = _errs21 === errors; -if(valid0){ -if(data.http2 !== undefined){ -let data8 = data.http2; -const _errs23 = errors; -if(typeof data8 !== "boolean"){ -let coerced9 = undefined; -if(!(coerced9 !== undefined)){ -if(data8 === "false" || data8 === 0 || data8 === null){ -coerced9 = false; -} -else if(data8 === "true" || data8 === 1){ -coerced9 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/http2",schemaPath:"#/properties/http2/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced9 !== undefined){ -data8 = coerced9; -if(data !== undefined){ -data["http2"] = coerced9; -} -} -} -var valid0 = _errs23 === errors; -} -else { -var valid0 = true; -} -if(valid0){ -if(data.https !== undefined){ -let data9 = data.https; -const _errs25 = errors; -const _errs26 = errors; -let valid2 = true; -const _errs27 = errors; -const _errs28 = errors; -const _errs29 = errors; -const _errs30 = errors; -let valid4 = false; -let passing1 = null; -const _errs31 = errors; -if(typeof data9 !== "boolean"){ -let coerced10 = undefined; -if(!(coerced10 !== undefined)){ -if(data9 === "false" || data9 === 0 || data9 === null){ -coerced10 = false; -} -else if(data9 === "true" || data9 === 1){ -coerced10 = true; -} -else { -const err4 = {}; -if(vErrors === null){ -vErrors = [err4]; -} -else { -vErrors.push(err4); -} -errors++; -} -} -if(coerced10 !== undefined){ -data9 = coerced10; -if(data !== undefined){ -data["https"] = coerced10; -} -} -} -var _valid2 = _errs31 === errors; -if(_valid2){ -valid4 = true; -passing1 = 0; -} -const _errs33 = errors; -if(data9 !== null){ -let coerced11 = undefined; -if(!(coerced11 !== undefined)){ -if(data9 === "" || data9 === 0 || data9 === false){ -coerced11 = null; -} -else { -const err5 = {}; -if(vErrors === null){ -vErrors = [err5]; -} -else { -vErrors.push(err5); -} -errors++; -} -} -if(coerced11 !== undefined){ -data9 = coerced11; -if(data !== undefined){ -data["https"] = coerced11; -} -} -} -var _valid2 = _errs33 === errors; -if(_valid2 && valid4){ -valid4 = false; -passing1 = [passing1, 1]; -} -else { -if(_valid2){ -valid4 = true; -passing1 = 1; -} -const _errs35 = errors; -if(errors === _errs35){ -if(data9 && typeof data9 == "object" && !Array.isArray(data9)){ -let missing0; -if((data9.allowHTTP1 === undefined) && (missing0 = "allowHTTP1")){ -const err6 = {}; -if(vErrors === null){ -vErrors = [err6]; -} -else { -vErrors.push(err6); -} -errors++; -} -else { -const _errs37 = errors; -for(const key1 in data9){ -if(!(key1 === "allowHTTP1")){ -delete data9[key1]; -} -} -if(_errs37 === errors){ -if(data9.allowHTTP1 !== undefined){ -let data10 = data9.allowHTTP1; -if(typeof data10 !== "boolean"){ -let coerced12 = undefined; -if(!(coerced12 !== undefined)){ -if(data10 === "false" || data10 === 0 || data10 === null){ -coerced12 = false; -} -else if(data10 === "true" || data10 === 1){ -coerced12 = true; -} -else { -const err7 = {}; -if(vErrors === null){ -vErrors = [err7]; -} -else { -vErrors.push(err7); -} -errors++; -} -} -if(coerced12 !== undefined){ -data10 = coerced12; -if(data9 !== undefined){ -data9["allowHTTP1"] = coerced12; -} -} -} -} -} -} -} -else { -const err8 = {}; -if(vErrors === null){ -vErrors = [err8]; -} -else { -vErrors.push(err8); -} -errors++; -} -} -var _valid2 = _errs35 === errors; -if(_valid2 && valid4){ -valid4 = false; -passing1 = [passing1, 2]; -} -else { -if(_valid2){ -valid4 = true; -passing1 = 2; -} -} -} -if(!valid4){ -const err9 = {}; -if(vErrors === null){ -vErrors = [err9]; -} -else { -vErrors.push(err9); -} -errors++; -} -else { -errors = _errs30; -if(vErrors !== null){ -if(_errs30){ -vErrors.length = _errs30; -} -else { -vErrors = null; -} -} -} -var valid3 = _errs29 === errors; -if(valid3){ -const err10 = {}; -if(vErrors === null){ -vErrors = [err10]; -} -else { -vErrors.push(err10); -} -errors++; -} -else { -errors = _errs28; -if(vErrors !== null){ -if(_errs28){ -vErrors.length = _errs28; -} -else { -vErrors = null; -} -} -} -var _valid1 = _errs27 === errors; -errors = _errs26; -if(vErrors !== null){ -if(_errs26){ -vErrors.length = _errs26; -} -else { -vErrors = null; -} -} -if(_valid1){ -const _errs40 = errors; -data["https"] = true; -var _valid1 = _errs40 === errors; -valid2 = _valid1; -} -if(!valid2){ -const err11 = {instancePath:instancePath+"/https",schemaPath:"#/properties/https/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"}; -if(vErrors === null){ -vErrors = [err11]; -} -else { -vErrors.push(err11); -} -errors++; -validate10.errors = vErrors; -return false; -} -var valid0 = _errs25 === errors; -} -else { -var valid0 = true; -} -if(valid0){ -let data11 = data.ignoreTrailingSlash; -const _errs41 = errors; -if(typeof data11 !== "boolean"){ -let coerced13 = undefined; -if(!(coerced13 !== undefined)){ -if(data11 === "false" || data11 === 0 || data11 === null){ -coerced13 = false; -} -else if(data11 === "true" || data11 === 1){ -coerced13 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/ignoreTrailingSlash",schemaPath:"#/properties/ignoreTrailingSlash/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced13 !== undefined){ -data11 = coerced13; -if(data !== undefined){ -data["ignoreTrailingSlash"] = coerced13; -} -} -} -var valid0 = _errs41 === errors; -if(valid0){ -let data12 = data.ignoreDuplicateSlashes; -const _errs43 = errors; -if(typeof data12 !== "boolean"){ -let coerced14 = undefined; -if(!(coerced14 !== undefined)){ -if(data12 === "false" || data12 === 0 || data12 === null){ -coerced14 = false; -} -else if(data12 === "true" || data12 === 1){ -coerced14 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/ignoreDuplicateSlashes",schemaPath:"#/properties/ignoreDuplicateSlashes/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced14 !== undefined){ -data12 = coerced14; -if(data !== undefined){ -data["ignoreDuplicateSlashes"] = coerced14; -} -} -} -var valid0 = _errs43 === errors; -if(valid0){ -let data13 = data.disableRequestLogging; -const _errs45 = errors; -if(typeof data13 !== "boolean"){ -let coerced15 = undefined; -if(!(coerced15 !== undefined)){ -if(data13 === "false" || data13 === 0 || data13 === null){ -coerced15 = false; -} -else if(data13 === "true" || data13 === 1){ -coerced15 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/disableRequestLogging",schemaPath:"#/properties/disableRequestLogging/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced15 !== undefined){ -data13 = coerced15; -if(data !== undefined){ -data["disableRequestLogging"] = coerced15; -} -} -} -var valid0 = _errs45 === errors; -if(valid0){ -let data14 = data.maxParamLength; -const _errs47 = errors; -if(!(((typeof data14 == "number") && (!(data14 % 1) && !isNaN(data14))) && (isFinite(data14)))){ -let dataType16 = typeof data14; -let coerced16 = undefined; -if(!(coerced16 !== undefined)){ -if(dataType16 === "boolean" || data14 === null - || (dataType16 === "string" && data14 && data14 == +data14 && !(data14 % 1))){ -coerced16 = +data14; -} -else { -validate10.errors = [{instancePath:instancePath+"/maxParamLength",schemaPath:"#/properties/maxParamLength/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced16 !== undefined){ -data14 = coerced16; -if(data !== undefined){ -data["maxParamLength"] = coerced16; -} -} -} -var valid0 = _errs47 === errors; -if(valid0){ -let data15 = data.onProtoPoisoning; -const _errs49 = errors; -if(typeof data15 !== "string"){ -let dataType17 = typeof data15; -let coerced17 = undefined; -if(!(coerced17 !== undefined)){ -if(dataType17 == "number" || dataType17 == "boolean"){ -coerced17 = "" + data15; -} -else if(data15 === null){ -coerced17 = ""; -} -else { -validate10.errors = [{instancePath:instancePath+"/onProtoPoisoning",schemaPath:"#/properties/onProtoPoisoning/type",keyword:"type",params:{type: "string"},message:"must be string"}]; -return false; -} -} -if(coerced17 !== undefined){ -data15 = coerced17; -if(data !== undefined){ -data["onProtoPoisoning"] = coerced17; -} -} -} -var valid0 = _errs49 === errors; -if(valid0){ -let data16 = data.onConstructorPoisoning; -const _errs51 = errors; -if(typeof data16 !== "string"){ -let dataType18 = typeof data16; -let coerced18 = undefined; -if(!(coerced18 !== undefined)){ -if(dataType18 == "number" || dataType18 == "boolean"){ -coerced18 = "" + data16; -} -else if(data16 === null){ -coerced18 = ""; -} -else { -validate10.errors = [{instancePath:instancePath+"/onConstructorPoisoning",schemaPath:"#/properties/onConstructorPoisoning/type",keyword:"type",params:{type: "string"},message:"must be string"}]; -return false; -} -} -if(coerced18 !== undefined){ -data16 = coerced18; -if(data !== undefined){ -data["onConstructorPoisoning"] = coerced18; -} -} -} -var valid0 = _errs51 === errors; -if(valid0){ -let data17 = data.pluginTimeout; -const _errs53 = errors; -if(!(((typeof data17 == "number") && (!(data17 % 1) && !isNaN(data17))) && (isFinite(data17)))){ -let dataType19 = typeof data17; -let coerced19 = undefined; -if(!(coerced19 !== undefined)){ -if(dataType19 === "boolean" || data17 === null - || (dataType19 === "string" && data17 && data17 == +data17 && !(data17 % 1))){ -coerced19 = +data17; -} -else { -validate10.errors = [{instancePath:instancePath+"/pluginTimeout",schemaPath:"#/properties/pluginTimeout/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced19 !== undefined){ -data17 = coerced19; -if(data !== undefined){ -data["pluginTimeout"] = coerced19; -} -} -} -var valid0 = _errs53 === errors; -if(valid0){ -let data18 = data.requestIdHeader; -const _errs55 = errors; -const _errs56 = errors; -let valid6 = false; -const _errs57 = errors; -if(typeof data18 !== "boolean"){ -let coerced20 = undefined; -if(!(coerced20 !== undefined)){ -if(data18 === "false" || data18 === 0 || data18 === null){ -coerced20 = false; -} -else if(data18 === "true" || data18 === 1){ -coerced20 = true; -} -else { -const err12 = {instancePath:instancePath+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/0/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}; -if(vErrors === null){ -vErrors = [err12]; -} -else { -vErrors.push(err12); -} -errors++; -} -} -if(coerced20 !== undefined){ -data18 = coerced20; -if(data !== undefined){ -data["requestIdHeader"] = coerced20; -} -} -} -var _valid3 = _errs57 === errors; -valid6 = valid6 || _valid3; -if(!valid6){ -const _errs59 = errors; -if(typeof data18 !== "string"){ -let dataType21 = typeof data18; -let coerced21 = undefined; -if(!(coerced21 !== undefined)){ -if(dataType21 == "number" || dataType21 == "boolean"){ -coerced21 = "" + data18; -} -else if(data18 === null){ -coerced21 = ""; -} -else { -const err13 = {instancePath:instancePath+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/1/type",keyword:"type",params:{type: "string"},message:"must be string"}; -if(vErrors === null){ -vErrors = [err13]; -} -else { -vErrors.push(err13); -} -errors++; -} -} -if(coerced21 !== undefined){ -data18 = coerced21; -if(data !== undefined){ -data["requestIdHeader"] = coerced21; -} -} -} -var _valid3 = _errs59 === errors; -valid6 = valid6 || _valid3; -} -if(!valid6){ -const err14 = {instancePath:instancePath+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"}; -if(vErrors === null){ -vErrors = [err14]; -} -else { -vErrors.push(err14); -} -errors++; -validate10.errors = vErrors; -return false; -} -else { -errors = _errs56; -if(vErrors !== null){ -if(_errs56){ -vErrors.length = _errs56; -} -else { -vErrors = null; -} -} -} -var valid0 = _errs55 === errors; -if(valid0){ -let data19 = data.requestIdLogLabel; -const _errs61 = errors; -if(typeof data19 !== "string"){ -let dataType22 = typeof data19; -let coerced22 = undefined; -if(!(coerced22 !== undefined)){ -if(dataType22 == "number" || dataType22 == "boolean"){ -coerced22 = "" + data19; -} -else if(data19 === null){ -coerced22 = ""; -} -else { -validate10.errors = [{instancePath:instancePath+"/requestIdLogLabel",schemaPath:"#/properties/requestIdLogLabel/type",keyword:"type",params:{type: "string"},message:"must be string"}]; -return false; -} -} -if(coerced22 !== undefined){ -data19 = coerced22; -if(data !== undefined){ -data["requestIdLogLabel"] = coerced22; -} -} -} -var valid0 = _errs61 === errors; -if(valid0){ -let data20 = data.http2SessionTimeout; -const _errs63 = errors; -if(!(((typeof data20 == "number") && (!(data20 % 1) && !isNaN(data20))) && (isFinite(data20)))){ -let dataType23 = typeof data20; -let coerced23 = undefined; -if(!(coerced23 !== undefined)){ -if(dataType23 === "boolean" || data20 === null - || (dataType23 === "string" && data20 && data20 == +data20 && !(data20 % 1))){ -coerced23 = +data20; -} -else { -validate10.errors = [{instancePath:instancePath+"/http2SessionTimeout",schemaPath:"#/properties/http2SessionTimeout/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; -return false; -} -} -if(coerced23 !== undefined){ -data20 = coerced23; -if(data !== undefined){ -data["http2SessionTimeout"] = coerced23; -} -} -} -var valid0 = _errs63 === errors; -if(valid0){ -let data21 = data.exposeHeadRoutes; -const _errs65 = errors; -if(typeof data21 !== "boolean"){ -let coerced24 = undefined; -if(!(coerced24 !== undefined)){ -if(data21 === "false" || data21 === 0 || data21 === null){ -coerced24 = false; -} -else if(data21 === "true" || data21 === 1){ -coerced24 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/exposeHeadRoutes",schemaPath:"#/properties/exposeHeadRoutes/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced24 !== undefined){ -data21 = coerced24; -if(data !== undefined){ -data["exposeHeadRoutes"] = coerced24; -} -} -} -var valid0 = _errs65 === errors; -if(valid0){ -let data22 = data.useSemicolonDelimiter; -const _errs67 = errors; -if(typeof data22 !== "boolean"){ -let coerced25 = undefined; -if(!(coerced25 !== undefined)){ -if(data22 === "false" || data22 === 0 || data22 === null){ -coerced25 = false; -} -else if(data22 === "true" || data22 === 1){ -coerced25 = true; -} -else { -validate10.errors = [{instancePath:instancePath+"/useSemicolonDelimiter",schemaPath:"#/properties/useSemicolonDelimiter/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}]; -return false; -} -} -if(coerced25 !== undefined){ -data22 = coerced25; -if(data !== undefined){ -data["useSemicolonDelimiter"] = coerced25; -} -} -} -var valid0 = _errs67 === errors; -if(valid0){ -if(data.constraints !== undefined){ -let data23 = data.constraints; -const _errs69 = errors; -if(errors === _errs69){ -if(data23 && typeof data23 == "object" && !Array.isArray(data23)){ -for(const key2 in data23){ -let data24 = data23[key2]; -const _errs72 = errors; -if(errors === _errs72){ -if(data24 && typeof data24 == "object" && !Array.isArray(data24)){ -let missing1; -if(((((data24.name === undefined) && (missing1 = "name")) || ((data24.storage === undefined) && (missing1 = "storage"))) || ((data24.validate === undefined) && (missing1 = "validate"))) || ((data24.deriveConstraint === undefined) && (missing1 = "deriveConstraint"))){ -validate10.errors = [{instancePath:instancePath+"/constraints/" + key2.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/constraints/additionalProperties/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}]; -return false; -} -else { -if(data24.name !== undefined){ -let data25 = data24.name; -if(typeof data25 !== "string"){ -let dataType26 = typeof data25; -let coerced26 = undefined; -if(!(coerced26 !== undefined)){ -if(dataType26 == "number" || dataType26 == "boolean"){ -coerced26 = "" + data25; -} -else if(data25 === null){ -coerced26 = ""; -} -else { -validate10.errors = [{instancePath:instancePath+"/constraints/" + key2.replace(/~/g, "~0").replace(/\//g, "~1")+"/name",schemaPath:"#/properties/constraints/additionalProperties/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}]; -return false; -} -} -if(coerced26 !== undefined){ -data25 = coerced26; -if(data24 !== undefined){ -data24["name"] = coerced26; -} -} -} -} -} -} -else { -validate10.errors = [{instancePath:instancePath+"/constraints/" + key2.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/constraints/additionalProperties/type",keyword:"type",params:{type: "object"},message:"must be object"}]; -return false; -} -} -var valid7 = _errs72 === errors; -if(!valid7){ -break; -} -} -} -else { -validate10.errors = [{instancePath:instancePath+"/constraints",schemaPath:"#/properties/constraints/type",keyword:"type",params:{type: "object"},message:"must be object"}]; -return false; -} -} -var valid0 = _errs69 === errors; -} -else { -var valid0 = true; -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -} -else { -validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; -return false; -} -} -validate10.errors = vErrors; -return errors === 0; -} - -module.exports.defaultInitOptions = {"connectionTimeout":0,"keepAliveTimeout":72000,"maxRequestsPerSocket":0,"requestTimeout":0,"bodyLimit":1048576,"caseSensitive":true,"allowUnsafeRegex":false,"disableRequestLogging":false,"ignoreTrailingSlash":false,"ignoreDuplicateSlashes":false,"maxParamLength":100,"onProtoPoisoning":"error","onConstructorPoisoning":"error","pluginTimeout":10000,"requestIdHeader":false,"requestIdLogLabel":"reqId","http2SessionTimeout":72000,"exposeHeadRoutes":true,"useSemicolonDelimiter":false} +module.exports.defaultInitOptions = { connectionTimeout: 0, keepAliveTimeout: 72000, maxRequestsPerSocket: 0, requestTimeout: 0, bodyLimit: 1048576, caseSensitive: true, allowUnsafeRegex: false, disableRequestLogging: false, ignoreTrailingSlash: false, ignoreDuplicateSlashes: false, maxParamLength: 100, onProtoPoisoning: 'error', onConstructorPoisoning: 'error', pluginTimeout: 10000, requestIdHeader: false, requestIdLogLabel: 'reqId', http2SessionTimeout: 72000, exposeHeadRoutes: true, useSemicolonDelimiter: false } /* c8 ignore stop */ diff --git a/lib/error-serializer.js b/lib/error-serializer.js index 71fb87b9ce..f0e0ae527d 100644 --- a/lib/error-serializer.js +++ b/lib/error-serializer.js @@ -1,120 +1,111 @@ // This file is autogenerated by build/build-error-serializer.js, do not edit /* c8 ignore start */ - 'use strict' +'use strict' - const Serializer = require('fast-json-stringify/lib/serializer') - const serializerState = {"mode":"standalone"} - const serializer = Serializer.restoreFromState(serializerState) +const Serializer = require('fast-json-stringify/lib/serializer') +const serializerState = { mode: 'standalone' } +const serializer = Serializer.restoreFromState(serializerState) - const validator = null +const validator = null - - module.exports = function anonymous(validator,serializer +module.exports = (function anonymous (validator, serializer ) { + const JSON_STR_BEGIN_OBJECT = '{' + const JSON_STR_END_OBJECT = '}' + const JSON_STR_BEGIN_ARRAY = '[' + const JSON_STR_END_ARRAY = ']' + const JSON_STR_COMMA = ',' + const JSON_STR_COLONS = ':' + const JSON_STR_QUOTE = '"' + const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT + const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY + const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE + const JSON_STR_NULL = 'null' - const JSON_STR_BEGIN_OBJECT = '{' - const JSON_STR_END_OBJECT = '}' - const JSON_STR_BEGIN_ARRAY = '[' - const JSON_STR_END_ARRAY = ']' - const JSON_STR_COMMA = ',' - const JSON_STR_COLONS = ':' - const JSON_STR_QUOTE = '"' - const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT - const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY - const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE - const JSON_STR_NULL = 'null' - - - - // # - function anonymous0 (input) { - const obj = (input && typeof input.toJSON === 'function') - ? input.toJSON() - : input - - if (obj === null) return JSON_STR_EMPTY_OBJECT - - let value -let json = JSON_STR_BEGIN_OBJECT -let addComma = false - - value = obj["statusCode"] - if (value !== undefined) { - !addComma && (addComma = true) || (json += JSON_STR_COMMA) - json += "\"statusCode\":" - json += serializer.asNumber(value) - } + // # + function anonymous0 (input) { + const obj = (input && typeof input.toJSON === 'function') + ? input.toJSON() + : input + + if (obj === null) return JSON_STR_EMPTY_OBJECT + + let value + let json = JSON_STR_BEGIN_OBJECT + let addComma = false + + value = obj.statusCode + if (value !== undefined) { + !addComma && (addComma = true) || (json += JSON_STR_COMMA) + json += '"statusCode":' + json += serializer.asNumber(value) + } + + value = obj.code + if (value !== undefined) { + !addComma && (addComma = true) || (json += JSON_STR_COMMA) + json += '"code":' - value = obj["code"] - if (value !== undefined) { - !addComma && (addComma = true) || (json += JSON_STR_COMMA) - json += "\"code\":" - - if (typeof value !== 'string') { - if (value === null) { - json += JSON_STR_EMPTY_STRING - } else if (value instanceof Date) { - json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE - } else if (value instanceof RegExp) { - json += serializer.asString(value.source) - } else { - json += serializer.asString(value.toString()) - } + if (typeof value !== 'string') { + if (value === null) { + json += JSON_STR_EMPTY_STRING + } else if (value instanceof Date) { + json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE + } else if (value instanceof RegExp) { + json += serializer.asString(value.source) } else { - json += serializer.asString(value) + json += serializer.asString(value.toString()) } - + } else { + json += serializer.asString(value) } + } + + value = obj.error + if (value !== undefined) { + !addComma && (addComma = true) || (json += JSON_STR_COMMA) + json += '"error":' - value = obj["error"] - if (value !== undefined) { - !addComma && (addComma = true) || (json += JSON_STR_COMMA) - json += "\"error\":" - - if (typeof value !== 'string') { - if (value === null) { - json += JSON_STR_EMPTY_STRING - } else if (value instanceof Date) { - json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE - } else if (value instanceof RegExp) { - json += serializer.asString(value.source) - } else { - json += serializer.asString(value.toString()) - } + if (typeof value !== 'string') { + if (value === null) { + json += JSON_STR_EMPTY_STRING + } else if (value instanceof Date) { + json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE + } else if (value instanceof RegExp) { + json += serializer.asString(value.source) } else { - json += serializer.asString(value) + json += serializer.asString(value.toString()) } - + } else { + json += serializer.asString(value) } + } + + value = obj.message + if (value !== undefined) { + !addComma && (addComma = true) || (json += JSON_STR_COMMA) + json += '"message":' - value = obj["message"] - if (value !== undefined) { - !addComma && (addComma = true) || (json += JSON_STR_COMMA) - json += "\"message\":" - - if (typeof value !== 'string') { - if (value === null) { - json += JSON_STR_EMPTY_STRING - } else if (value instanceof Date) { - json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE - } else if (value instanceof RegExp) { - json += serializer.asString(value.source) - } else { - json += serializer.asString(value.toString()) - } + if (typeof value !== 'string') { + if (value === null) { + json += JSON_STR_EMPTY_STRING + } else if (value instanceof Date) { + json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE + } else if (value instanceof RegExp) { + json += serializer.asString(value.source) } else { - json += serializer.asString(value) + json += serializer.asString(value.toString()) } - + } else { + json += serializer.asString(value) } + } return json + JSON_STR_END_OBJECT - - } - - const main = anonymous0 - return main - -}(validator, serializer) + } + + const main = anonymous0 + return main +}(validator, serializer)) /* c8 ignore stop */ diff --git a/package.json b/package.json index 3213b8556e..ecd3c77f4f 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,7 @@ } ], "devDependencies": { + "@dancastillo/testing-borp-with-fastify": "^0.17.6", "@fastify/pre-commit": "^2.1.0", "@sinclair/typebox": "^0.33.4", "@sinonjs/fake-timers": "^11.2.2", @@ -162,7 +163,6 @@ "ajv-i18n": "^4.2.0", "ajv-merge-patch": "^5.0.1", "autocannon": "^7.15.0", - "borp": "^0.17.0", "branch-comparer": "^1.1.0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", diff --git a/test/schema-serialization.test.js b/test/schema-serialization.test.js index b319be02b0..5a8135a6fa 100644 --- a/test/schema-serialization.test.js +++ b/test/schema-serialization.test.js @@ -251,7 +251,7 @@ test('Different content types', t => { } } }, function (req, reply) { - switch (req.headers['code']) { + switch (req.headers.code) { case '200': { reply.header('Content-Type', 'application/json') reply.code(200).send({ age: 18, city: 'AU' })