Home / File/ route.6.test.js — fastify Source File

route.6.test.js — fastify Source File

Architecture documentation for route.6.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const stream = require('node:stream')
const { ReadableStream } = require('node:stream/web')
const { test } = require('node:test')
const Fastify = require('..')

test('Creates a HEAD route for a GET one with prefixTrailingSlash', async (t) => {
  t.plan(1)

  const fastify = Fastify()

  const arr = []
  fastify.register((instance, opts, next) => {
    instance.addHook('onRoute', (routeOptions) => {
      arr.push(`${routeOptions.method} ${routeOptions.url}`)
    })

    instance.route({
      method: 'GET',
      path: '/',
      exposeHeadRoute: true,
      prefixTrailingSlash: 'both',
      handler: (req, reply) => {
        reply.send({ here: 'is coffee' })
      }
    })

    next()
  }, { prefix: '/v1' })

  await fastify.ready()

  t.assert.ok(true)
})

test('Will not create a HEAD route that is not GET', async t => {
  t.plan(8)

  const fastify = Fastify({ exposeHeadRoutes: true })

  fastify.route({
    method: 'GET',
    path: '/more-coffee',
    handler: (req, reply) => {
      reply.send({ here: 'is coffee' })
    }
  })

  fastify.route({
    method: 'GET',
    path: '/some-light',
    handler: (req, reply) => {
      reply.send()
    }
  })

  fastify.route({
    method: 'POST',
    path: '/something',
// ... (247 more lines)

Frequently Asked Questions

What does route.6.test.js do?
route.6.test.js is a source file in the fastify codebase, written in javascript.
Where is route.6.test.js in the architecture?
route.6.test.js is located at test/route.6.test.js (directory: test).

Analyze Your Own Codebase

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

Try Supermodel Free