Home / Function/ handler() — fastify Function Reference

handler() — fastify Function Reference

Architecture documentation for the handler() function in serialize-response.test.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  5194e422_0449_67d9_2f17_06b67776ab18["handler()"]
  3054fe3a_84be_26cd_7f16_b7e78727aa2c["serialize-response.test.js"]
  5194e422_0449_67d9_2f17_06b67776ab18 -->|defined in| 3054fe3a_84be_26cd_7f16_b7e78727aa2c
  style 5194e422_0449_67d9_2f17_06b67776ab18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

test/serialize-response.test.js lines 74–106

const handler = (request, reply) => {
  if (request.body.id === '400') {
    return reply.status(400).send({
      statusCode: 400,
      error: 'Bad Request',
      message: 'Custom message',
      extra: 'This should not be in the response'
    })
  }

  if (request.body.id === '404') {
    return reply.status(404).send({
      statusCode: 404,
      error: 'Not Found',
      message: 'Custom Not Found',
      extra: 'This should not be in the response'
    })
  }

  if (request.body.id === '500') {
    reply.status(500).send({
      statusCode: 500,
      error: 'Internal Server Error',
      message: 'Custom Internal Server Error',
      extra: 'This should not be in the response'
    })
  }

  reply.send({
    id: request.body.id,
    extra: 'This should not be in the response'
  })
}

Domain

Subdomains

Frequently Asked Questions

What does handler() do?
handler() is a function in the fastify codebase, defined in test/serialize-response.test.js.
Where is handler() defined?
handler() is defined in test/serialize-response.test.js at line 74.

Analyze Your Own Codebase

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

Try Supermodel Free