axios-light-my-request-adapter
Version:
Axios adapter for Light my Request
37 lines (36 loc) • 1.55 kB
TypeScript
/// <reference types="node" />
import { AxiosAdapter } from "axios";
import http from "http";
import { DispatchFunc } from "light-my-request";
export interface LightMyRequestAdapterOptions {
/** 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 an `AxiosAdapter` that will inject requests/responses into `dispatchFunc` via Light my
* Request.
*
* @param dispatchFunc - Listener function. The same as you would pass to `http.createServer` when
* making a node HTTP server.
* @param opts - Additional options
* @returns An `AxiosAdapter`
*/
export declare function createLightMyRequestAdapter(dispatchFunc: DispatchFunc, opts?: LightMyRequestAdapterOptions): AxiosAdapter;
/**
* Simple interface for a `FastifyInstance` for {@link createLightMyRequestAdapterFromFastify}.
*/
export interface FastifyInstance {
routing(req: unknown, res: unknown): void;
ready(readyListener: (err: Error) => void): FastifyInstance;
}
/**
* Create an `AxiosAdapter` that will inject requests/responses into the Fastify `instance` via
* Light my Request.
*
* @param instance - A Fastify instance.
* @param opts - Additional options
* @returns An `AxiosAdapter`
*/
export declare function createLightMyRequestAdapterFromFastify(instance: FastifyInstance, opts?: LightMyRequestAdapterOptions): AxiosAdapter;