Home / Function/ Context() — fastify Function Reference

Context() — fastify Function Reference

Architecture documentation for the Context() function in context.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  e6cd6664_e3e9_2d70_49ea_8b7fe0401f91["Context()"]
  39cb219c_7ca6_c183_e0a5_d246f37be386["context.js"]
  e6cd6664_e3e9_2d70_49ea_8b7fe0401f91 -->|defined in| 39cb219c_7ca6_c183_e0a5_d246f37be386
  style e6cd6664_e3e9_2d70_49ea_8b7fe0401f91 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/context.js lines 22–82

function Context ({
  schema,
  handler,
  config,
  requestIdLogLabel,
  childLoggerFactory,
  errorHandler,
  bodyLimit,
  logLevel,
  logSerializers,
  attachValidation,
  validatorCompiler,
  serializerCompiler,
  replySerializer,
  schemaErrorFormatter,
  exposeHeadRoute,
  prefixTrailingSlash,
  server,
  isFastify
}) {
  this.schema = schema
  this.handler = handler
  this.Reply = server[kReply]
  this.Request = server[kRequest]
  this.contentTypeParser = server[kContentTypeParser]
  this.onRequest = null
  this.onSend = null
  this.onError = null
  this.onTimeout = null
  this.preHandler = null
  this.onResponse = null
  this.preSerialization = null
  this.onRequestAbort = null
  this.config = config
  this.errorHandler = errorHandler || server[kErrorHandler]
  this.requestIdLogLabel = requestIdLogLabel || server[kOptions].requestIdLogLabel
  this.childLoggerFactory = childLoggerFactory || server[kChildLoggerFactory]
  this._middie = null
  this._parserOptions = {
    limit: bodyLimit || server[kBodyLimit]
  }
  this.exposeHeadRoute = exposeHeadRoute
  this.prefixTrailingSlash = prefixTrailingSlash
  this.logLevel = logLevel || server[kLogLevel]
  this.logSerializers = logSerializers
  this[kFourOhFourContext] = null
  this.attachValidation = attachValidation
  this[kReplySerializerDefault] = replySerializer
  this.schemaErrorFormatter =
    schemaErrorFormatter ||
    server[kSchemaErrorFormatter] ||
    defaultSchemaErrorFormatter
  this[kRouteByFastify] = isFastify

  this[kRequestCacheValidateFns] = null
  this[kReplyCacheSerializeFns] = null
  this.validatorCompiler = validatorCompiler || null
  this.serializerCompiler = serializerCompiler || null

  this.server = server
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Context() do?
Context() is a function in the fastify codebase, defined in lib/context.js.
Where is Context() defined?
Context() is defined in lib/context.js at line 22.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free