plugin.test-d.ts — fastify Source File
Architecture documentation for plugin.test-d.ts, a typescript file in the fastify codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0["plugin.test-d.ts"] 2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> 2bf9986b_b7fb_0c78_f075_72fbe6f4672b ef0b4019_4e15_bb8c_0e07_0575207a4dcc["./plugin"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> ef0b4019_4e15_bb8c_0e07_0575207a4dcc bd94e3ff_2705_51a0_bac0_884f2c38b615["node:http"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> bd94e3ff_2705_51a0_bac0_884f2c38b615 663b99b5_576e_9407_ccf2_377b37f4ae0d["node:https"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> 663b99b5_576e_9407_ccf2_377b37f4ae0d 1741b237_9033_f1d9_f91f_94ad04e621d4["tsd"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> 1741b237_9033_f1d9_f91f_94ad04e621d4 473a42a8_a580_301b_42c4_5215be78511b["error"] 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 --> 473a42a8_a580_301b_42c4_5215be78511b style 12df0826_8bcf_1fe2_3d31_5d4337ccf3c0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fastify, { FastifyInstance, FastifyPluginOptions, SafePromiseLike } from '../../fastify'
import * as http from 'node:http'
import * as https from 'node:https'
import { expectType, expectError, expectAssignable } from 'tsd'
import { FastifyPluginCallback, FastifyPluginAsync } from '../../types/plugin'
import { FastifyError } from '@fastify/error'
// FastifyPlugin & FastifyRegister
interface TestOptions extends FastifyPluginOptions {
option1: string;
option2: boolean;
}
const testOptions: TestOptions = {
option1: 'a',
option2: false
}
const testPluginOpts: FastifyPluginCallback<TestOptions> = function (instance, opts, done) {
expectType<TestOptions>(opts)
}
const testPluginOptsAsync: FastifyPluginAsync<TestOptions> = async function (instance, opts) {
expectType<TestOptions>(opts)
}
const testPluginOptsWithType = (
instance: FastifyInstance,
opts: FastifyPluginOptions,
done: (error?: FastifyError) => void
) => { }
const testPluginOptsWithTypeAsync = async (
instance: FastifyInstance,
opts: FastifyPluginOptions
) => { }
expectError(fastify().register(testPluginOpts, {})) // error because missing required options from generic declaration
expectError(fastify().register(testPluginOptsAsync, {})) // error because missing required options from generic declaration
expectAssignable<FastifyInstance>(fastify().register(testPluginOpts, { option1: '', option2: true }))
expectAssignable<FastifyInstance>(fastify().register(testPluginOptsAsync, { option1: '', option2: true }))
expectAssignable<FastifyInstance>(fastify().register(function (instance, opts, done) { }))
expectAssignable<FastifyInstance>(fastify().register(function (instance, opts, done) { }, () => { }))
expectAssignable<FastifyInstance>(fastify().register(function (instance, opts, done) { }, { logLevel: 'info', prefix: 'foobar' }))
expectAssignable<FastifyInstance>(fastify().register(import('./dummy-plugin')))
expectAssignable<FastifyInstance>(fastify().register(import('./dummy-plugin'), { foo: 1 }))
const testPluginCallback: FastifyPluginCallback = function (instance, opts, done) { }
expectAssignable<FastifyInstance>(fastify().register(testPluginCallback, {}))
const testPluginAsync: FastifyPluginAsync = async function (instance, opts) { }
expectAssignable<FastifyInstance>(fastify().register(testPluginAsync, {}))
expectAssignable<FastifyInstance>(
fastify().register(function (instance, opts): Promise<void> { return Promise.resolve() })
)
expectAssignable<FastifyInstance>(fastify().register(async function (instance, opts) { }, () => { }))
expectAssignable<FastifyInstance>(fastify().register(async function (instance, opts) { }, { logLevel: 'info', prefix: 'foobar' }))
expectError(fastify().register(function (instance, opts, done) { }, { ...testOptions, logLevel: '' })) // must use a valid logLevel
const httpsServer = fastify({ https: {} })
expectError<
FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse> &
Promise<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse>>
>(httpsServer)
expectAssignable<
FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse> &
PromiseLike<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse>>
>(httpsServer)
expectType<
FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse> &
SafePromiseLike<FastifyInstance<https.Server, http.IncomingMessage, http.ServerResponse>>
>(httpsServer)
// Chainable
httpsServer
.register(testPluginOpts, testOptions)
.after((_error) => { })
.ready((_error) => { })
.close(() => { })
// Thenable
expectAssignable<PromiseLike<undefined>>(httpsServer.after())
expectAssignable<PromiseLike<undefined>>(httpsServer.close())
expectAssignable<PromiseLike<undefined>>(httpsServer.ready())
expectAssignable<PromiseLike<undefined>>(httpsServer.register(testPluginOpts, testOptions))
expectAssignable<PromiseLike<undefined>>(httpsServer.register(testPluginOptsWithType))
expectAssignable<PromiseLike<undefined>>(httpsServer.register(testPluginOptsWithTypeAsync))
expectAssignable<PromiseLike<undefined>>(httpsServer.register(testPluginOptsWithType, { prefix: '/test' }))
expectAssignable<PromiseLike<undefined>>(httpsServer.register(testPluginOptsWithTypeAsync, { prefix: '/test' }))
/* eslint-disable @typescript-eslint/no-unused-vars */
async function testAsync (): Promise<void> {
await httpsServer
.register(testPluginOpts, testOptions)
.register(testPluginOpts, testOptions)
}
Domain
Subdomains
Functions
Types
Dependencies
- ./plugin
- error
- fastify.js
- node:http
- node:https
- tsd
Source
Frequently Asked Questions
What does plugin.test-d.ts do?
plugin.test-d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in plugin.test-d.ts?
plugin.test-d.ts defines 7 function(s): testAsync, testPluginAsync, testPluginCallback, testPluginOpts, testPluginOptsAsync, testPluginOptsWithType, testPluginOptsWithTypeAsync.
What does plugin.test-d.ts depend on?
plugin.test-d.ts imports 6 module(s): ./plugin, error, fastify.js, node:http, node:https, tsd.
Where is plugin.test-d.ts in the architecture?
plugin.test-d.ts is located at test/types/plugin.test-d.ts (domain: CoreKernel, subdomain: InstanceFactory, directory: test/types).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free