Home / Function/ serializeInput() — fastify Function Reference

serializeInput() — fastify Function Reference

Architecture documentation for the serializeInput() function in reply.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  2142f433_1d66_ceb5_1102_19519632e0ad["serializeInput()"]
  4bcd71dc_1ec2_5fe8_b8ff_4a371e392925["reply.js"]
  2142f433_1d66_ceb5_1102_19519632e0ad -->|defined in| 4bcd71dc_1ec2_5fe8_b8ff_4a371e392925
  89249428_ed5b_6713_ea5a_4045befd0d35["compileSerializationSchema()"]
  2142f433_1d66_ceb5_1102_19519632e0ad -->|calls| 89249428_ed5b_6713_ea5a_4045befd0d35
  d2dc4a04_6060_c578_97dc_da6f3dd4da06["serialize()"]
  2142f433_1d66_ceb5_1102_19519632e0ad -->|calls| d2dc4a04_6060_c578_97dc_da6f3dd4da06
  style 2142f433_1d66_ceb5_1102_19519632e0ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/reply.js lines 381–413

Reply.prototype.serializeInput = function (input, schema, httpStatus, contentType) {
  const possibleContentType = httpStatus
  let serialize
  httpStatus = typeof schema === 'string' || typeof schema === 'number'
    ? schema
    : httpStatus

  contentType = httpStatus && possibleContentType !== httpStatus
    ? possibleContentType
    : contentType

  if (httpStatus != null) {
    if (contentType != null) {
      serialize = this[kRouteContext][kSchemaResponse]?.[httpStatus]?.[contentType]
    } else {
      serialize = this[kRouteContext][kSchemaResponse]?.[httpStatus]
    }

    if (serialize == null) {
      if (contentType) throw new FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN(httpStatus, contentType)
      throw new FST_ERR_MISSING_SERIALIZATION_FN(httpStatus)
    }
  } else {
    // Check if serialize function already compiled
    if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
      serialize = this[kRouteContext][kReplyCacheSerializeFns].get(schema)
    } else {
      serialize = this.compileSerializationSchema(schema, httpStatus, contentType)
    }
  }

  return serialize(input)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does serializeInput() do?
serializeInput() is a function in the fastify codebase, defined in lib/reply.js.
Where is serializeInput() defined?
serializeInput() is defined in lib/reply.js at line 381.
What does serializeInput() call?
serializeInput() calls 2 function(s): compileSerializationSchema, serialize.

Analyze Your Own Codebase

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

Try Supermodel Free