Home / File/ hooks-benchmark.js — fastify Source File

hooks-benchmark.js — fastify Source File

Architecture documentation for hooks-benchmark.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const fastify = require('../../fastify')({ logger: false })

const opts = {
  schema: {
    response: {
      200: {
        type: 'object',
        properties: {
          hello: {
            type: 'string'
          }
        }
      }
    }
  }
}

fastify
  .addHook('onRequest', function (request, reply, done) {
    done()
  })
  .addHook('onRequest', function (request, reply, done) {
    done()
  })

fastify
  .addHook('preHandler', function (request, reply, done) {
    done()
  })
  .addHook('preHandler', function (request, reply, done) {
    setImmediate(done)
  })
  .addHook('preHandler', function (request, reply, done) {
    done()
  })

fastify
  .addHook('onSend', function (request, reply, payload, done) {
    done()
  })

fastify.get('/', opts, function (request, reply) {
  reply.send({ hello: 'world' })
})

fastify.listen({ port: 3000 }, function (err) {
  if (err) {
    throw err
  }
})

Frequently Asked Questions

What does hooks-benchmark.js do?
hooks-benchmark.js is a source file in the fastify codebase, written in javascript.
Where is hooks-benchmark.js in the architecture?
hooks-benchmark.js is located at examples/benchmark/hooks-benchmark.js (directory: examples/benchmark).

Analyze Your Own Codebase

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

Try Supermodel Free