UNPKG

fetch-light-my-request

Version:
36 lines (35 loc) 1.52 kB
import http from "node:http"; import { DispatchFunc } from "light-my-request"; import { FetchMock } from "fetch-mock"; import type { FastifyInstance } from "fastify"; /** * Options for the created fetch mock. */ export interface FetchLightMyRequestOptions { /** Optional http server. It is used for binding the `dispatchFunc` */ server?: http.Server; /** an optional string specifying the client remote address. Defaults to '127.0.0.1' */ remoteAddress?: string; } /** * Create a [FetchMock] from a light-my-request dispatch function. * * [FetchMock]: https://www.wheresrhys.co.uk/fetch-mock/docs */ export declare function createFetchMockLightMyRequest(dispatchFunc: DispatchFunc, opts?: FetchLightMyRequestOptions): FetchMock; /** * Create a mock fetch function (Directly returning the `FetchMock.fetchHandler`) from a * light-my-request dispatch function. */ export declare function createFetchLightMyRequest(dispatchFunc: DispatchFunc, opts?: FetchLightMyRequestOptions): typeof fetch; /** * Create a [FetchMock] from a Fastify server. * * [FetchMock]: https://www.wheresrhys.co.uk/fetch-mock/docs */ export declare function createFetchMockLightMyRequestFromFastify(instance: FastifyInstance, opts?: FetchLightMyRequestOptions): FetchMock; /** * Create a mock fetch function (Directly returning the `FetchMock.fetchHandler`) from Fastify * server. */ export declare function createFetchLightMyRequestFromFastify(instance: FastifyInstance, opts?: FetchLightMyRequestOptions): typeof fetch;