Home / File/ route.test-d.ts — fastify Source File

route.test-d.ts — fastify Source File

Architecture documentation for route.test-d.ts, a typescript file in the fastify codebase. 7 imports, 0 dependents.

File typescript CoreKernel LifecycleManager 7 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  bd669693_d0d9_c28e_3452_91e019653d6f["route.test-d.ts"]
  2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> 2bf9986b_b7fb_0c78_f075_72fbe6f4672b
  ce8cd88b_1c50_7142_5167_00ce90d3f4fc["./hooks"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> ce8cd88b_1c50_7142_5167_00ce90d3f4fc
  531c9fc1_aab6_113a_24da_d449700fa629["./instance"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> 531c9fc1_aab6_113a_24da_d449700fa629
  36d8862b_caf4_88a2_ba4d_4f7ed0738291["./utils"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> 36d8862b_caf4_88a2_ba4d_4f7ed0738291
  473a42a8_a580_301b_42c4_5215be78511b["error"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> 473a42a8_a580_301b_42c4_5215be78511b
  bd94e3ff_2705_51a0_bac0_884f2c38b615["node:http"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> bd94e3ff_2705_51a0_bac0_884f2c38b615
  1741b237_9033_f1d9_f91f_94ad04e621d4["tsd"]
  bd669693_d0d9_c28e_3452_91e019653d6f --> 1741b237_9033_f1d9_f91f_94ad04e621d4
  style bd669693_d0d9_c28e_3452_91e019653d6f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { FastifyError } from '@fastify/error'
import * as http from 'node:http'
import { expectAssignable, expectError, expectType } from 'tsd'
import fastify, { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from '../../fastify'
import { RequestPayload } from '../../types/hooks'
import { FindMyWayFindResult } from '../../types/instance'
import { HTTPMethods, RawServerDefault } from '../../types/utils'

/*
 * Testing Fastify HTTP Routes and Route Shorthands.
 * Verifies Request and Reply types as well.
 * For the route shorthand tests the argument orders are:
 * - `(path, handler)`
 * - `(path, options, handler)`
 * - `(path, options)`
 */

declare module '../../fastify' {
  interface FastifyContextConfig {
    foo: string;
    bar: number;
    includeMessage?: boolean;
  }

  /* eslint-disable @typescript-eslint/no-unused-vars */
  interface FastifyRequest<
    RouteGeneric,
    RawServer,
    RawRequest,
    SchemaCompiler,
    TypeProvider,
    ContextConfig,
    Logger,
    RequestType
  > {
    message: ContextConfig extends { includeMessage: true }
      ? string
      : null;
  }
}

const routeHandler: RouteHandlerMethod = function (request, reply) {
  expectType<FastifyInstance>(this)
  expectType<FastifyRequest>(request)
  expectType<FastifyReply>(reply)
}

const routeHandlerWithReturnValue: RouteHandlerMethod = function (request, reply) {
  expectType<FastifyInstance>(this)
  expectType<FastifyRequest>(request)
  expectType<FastifyReply>(reply)

  return reply.send()
}

fastify().get(
  '/',
  { config: { foo: 'bar', bar: 100, includeMessage: true } },
  (req) => {
    expectType<string>(req.message)
// ... (488 more lines)

Domain

Subdomains

Dependencies

  • ./hooks
  • ./instance
  • ./utils
  • error
  • fastify.js
  • node:http
  • tsd

Frequently Asked Questions

What does route.test-d.ts do?
route.test-d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
What functions are defined in route.test-d.ts?
route.test-d.ts defines 2 function(s): routeHandler, routeHandlerWithReturnValue.
What does route.test-d.ts depend on?
route.test-d.ts imports 7 module(s): ./hooks, ./instance, ./utils, error, fastify.js, node:http, tsd.
Where is route.test-d.ts in the architecture?
route.test-d.ts is located at test/types/route.test-d.ts (domain: CoreKernel, subdomain: LifecycleManager, directory: test/types).

Analyze Your Own Codebase

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

Try Supermodel Free