Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
AgentOptions as SecureAgentOptions,
RequestOptions as SecureRequestOptions
} from 'https'
import { Pool, ProxyAgent } from 'undici'
import { Pool, ProxyAgent, Dispatcher } from 'undici'

declare module 'fastify' {
interface FastifyReply {
Expand Down Expand Up @@ -104,7 +104,7 @@ declare namespace fastifyReplyFrom {
disableCache?: boolean;
http?: HttpOptions;
http2?: Http2Options | boolean;
undici?: Pool.Options & { proxy?: string | URL | ProxyAgent.Options };
undici?: Pool.Options & { proxy?: string | URL | ProxyAgent.Options } | { request: Dispatcher['request'] };
contentTypesToEncode?: string[];
retryMethods?: (HTTPMethods | 'TRACE')[];
maxRetriesOn503?: number;
Expand Down
29 changes: 29 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IncomingHttpHeaders } from 'http2'
import * as https from 'node:https'
import { AddressInfo } from 'net'
import { expectType } from 'tsd'
import { Agent, Client, Dispatcher, Pool } from 'undici'
import replyFrom, { FastifyReplyFromOptions } from '..'
// @ts-ignore
import tap from 'tap'
Expand Down Expand Up @@ -158,6 +159,34 @@ async function main () {
})
await undiciInstance.ready()

const undiciInstanceAgent = fastify()
undiciInstance.register(replyFrom, {
base: 'http://example2.com',
undici: new Agent()
})
await undiciInstanceAgent.ready()

const undiciInstancePool = fastify()
undiciInstance.register(replyFrom, {
base: 'http://example2.com',
undici: new Pool('http://example2.com')
})
await undiciInstancePool.ready()

const undiciInstanceClient = fastify()
undiciInstance.register(replyFrom, {
base: 'http://example2.com',
undici: new Client('http://example2.com')
})
await undiciInstanceClient.ready()

const undiciInstanceDispatcher = fastify()
undiciInstance.register(replyFrom, {
base: 'http://example2.com',
undici: new Dispatcher()
})
await undiciInstanceDispatcher.ready()

tap.pass('done')
tap.end()
}
Expand Down
Loading