processOptions() — fastify Function Reference
Architecture documentation for the processOptions() function in fastify.js from the fastify codebase.
Entity Profile
Dependency Diagram
graph TD 61ade40f_2777_d754_2bed_3fac253432e5["processOptions()"] 2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"] 61ade40f_2777_d754_2bed_3fac253432e5 -->|defined in| 2bf9986b_b7fb_0c78_f075_72fbe6f4672b 54cbea5e_a399_a298_5819_f2791a26c65c["fastify()"] 54cbea5e_a399_a298_5819_f2791a26c65c -->|calls| 61ade40f_2777_d754_2bed_3fac253432e5 style 61ade40f_2777_d754_2bed_3fac253432e5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastify.js lines 822–906
function processOptions (options, defaultRoute, onBadUrl) {
// Options validations
if (options && typeof options !== 'object') {
throw new FST_ERR_OPTIONS_NOT_OBJ()
} else {
// Shallow copy options object to prevent mutations outside of this function
options = Object.assign({}, options)
}
if (
(options.querystringParser && typeof options.querystringParser !== 'function') ||
(
options.routerOptions?.querystringParser &&
typeof options.routerOptions.querystringParser !== 'function'
)
) {
throw new FST_ERR_QSP_NOT_FN(typeof (options.querystringParser ?? options.routerOptions.querystringParser))
}
if (options.schemaController && options.schemaController.bucket && typeof options.schemaController.bucket !== 'function') {
throw new FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN(typeof options.schemaController.bucket)
}
validateBodyLimitOption(options.bodyLimit)
const requestIdHeader = typeof options.requestIdHeader === 'string' && options.requestIdHeader.length !== 0 ? options.requestIdHeader.toLowerCase() : (options.requestIdHeader === true && 'request-id')
const genReqId = reqIdGenFactory(requestIdHeader, options.genReqId)
const requestIdLogLabel = options.requestIdLogLabel || 'reqId'
options.bodyLimit = options.bodyLimit || defaultInitOptions.bodyLimit
const disableRequestLogging = options.disableRequestLogging || false
const ajvOptions = Object.assign({
customOptions: {},
plugins: []
}, options.ajv)
if (!ajvOptions.customOptions || Object.prototype.toString.call(ajvOptions.customOptions) !== '[object Object]') {
throw new FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ(typeof ajvOptions.customOptions)
}
if (!ajvOptions.plugins || !Array.isArray(ajvOptions.plugins)) {
throw new FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR(typeof ajvOptions.plugins)
}
const { logger, hasLogger } = createLogger(options)
// Update the options with the fixed values
options.connectionTimeout = options.connectionTimeout || defaultInitOptions.connectionTimeout
options.keepAliveTimeout = options.keepAliveTimeout || defaultInitOptions.keepAliveTimeout
options.maxRequestsPerSocket = options.maxRequestsPerSocket || defaultInitOptions.maxRequestsPerSocket
options.requestTimeout = options.requestTimeout || defaultInitOptions.requestTimeout
options.logger = logger
options.requestIdHeader = requestIdHeader
options.requestIdLogLabel = requestIdLogLabel
options.disableRequestLogging = disableRequestLogging
options.ajv = ajvOptions
options.clientErrorHandler = options.clientErrorHandler || defaultClientErrorHandler
options.allowErrorHandlerOverride = options.allowErrorHandlerOverride ?? defaultInitOptions.allowErrorHandlerOverride
const initialConfig = getSecuredInitialConfig(options)
// exposeHeadRoutes have its default set from the validator
options.exposeHeadRoutes = initialConfig.exposeHeadRoutes
// we need to set this before calling createServer
options.http2SessionTimeout = initialConfig.http2SessionTimeout
options.routerOptions = buildRouterOptions(options, {
defaultRoute,
onBadUrl,
ignoreTrailingSlash: defaultInitOptions.ignoreTrailingSlash,
ignoreDuplicateSlashes: defaultInitOptions.ignoreDuplicateSlashes,
maxParamLength: defaultInitOptions.maxParamLength,
allowUnsafeRegex: defaultInitOptions.allowUnsafeRegex,
buildPrettyMeta: defaultBuildPrettyMeta,
useSemicolonDelimiter: defaultInitOptions.useSemicolonDelimiter
})
return {
options,
genReqId,
disableRequestLogging,
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does processOptions() do?
processOptions() is a function in the fastify codebase, defined in fastify.js.
Where is processOptions() defined?
processOptions() is defined in fastify.js at line 822.
What calls processOptions()?
processOptions() is called by 1 function(s): fastify.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free