Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -7,7 +7,7 @@ const {
kSchemaBody: bodySchema,
kSchemaResponse: responseSchema
} = require('./symbols')
const scChecker = /^[1-5]{1}[0-9]{2}$|^[1-5]xx$|^default$/
const scChecker = /^[1-5](?:\d{2}|xx)$|^default$/
const {
FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX
@@ -24,7 +24,7 @@ function compileSchemasForSerialization (context, compile) {
.reduce(function (acc, statusCode) {
const schema = context.schema.response[statusCode]
statusCode = statusCode.toLowerCase()
if (!scChecker.exec(statusCode)) {
if (!scChecker.test(statusCode)) {
throw new FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX()
}
@@ -82,7 +82,7 @@ function compileSchemasForValidation (context, compile, isCustom) {
})
}
context[headersSchema] = compile({ schema: headersSchemaLowerCase, method, url, httpPart: 'headers' })
} else if (Object.prototype.hasOwnProperty.call(schema, 'headers')) {
} else if (Object.hasOwn(schema, 'headers')) {
FSTWRN001('headers', method, url)
}
@@ -98,28 +98,36 @@ function compileSchemasForValidation (context, compile, isCustom) {
} else {
context[bodySchema] = compile({ schema: schema.body, method, url, httpPart: 'body' })
}
} else if (Object.prototype.hasOwnProperty.call(schema, 'body')) {
} else if (Object.hasOwn(schema, 'body')) {
FSTWRN001('body', method, url)
}
if (schema.querystring) {
context[querystringSchema] = compile({ schema: schema.querystring, method, url, httpPart: 'querystring' })
} else if (Object.prototype.hasOwnProperty.call(schema, 'querystring')) {
} else if (Object.hasOwn(schema, 'querystring')) {
FSTWRN001('querystring', method, url)
}
if (schema.params) {
context[paramsSchema] = compile({ schema: schema.params, method, url, httpPart: 'params' })
} else if (Object.prototype.hasOwnProperty.call(schema, 'params')) {
} else if (Object.hasOwn(schema, 'params')) {
FSTWRN001('params', method, url)
}
}
function validateParam (validatorFunction, request, paramName) {
const isUndefined = request[paramName] === undefined
const ret = validatorFunction && validatorFunction(isUndefined ? null : request[paramName])
let ret
if (ret?.then) {
try {
ret = validatorFunction?.(isUndefined ? null : request[paramName])
} catch (err) {
// If validator throws synchronously, ensure it propagates as an internal error
err.statusCode = 500
return err
}
if (ret && typeof ret.then === 'function') {
return ret
.then((res) => { return answer(res) })
.catch(err => { return err }) // return as simple error (not throw)