Registry / testing / axios-light-my-request-adapter

axios-light-my-request-adapter

JSON →
library0.4.0jsnpmunverified

Axios adapter that uses Light my Request to inject HTTP requests without a real server, ideal for testing Fastify or Node.js HTTP handlers. Current stable version: 0.4.0. Release cadence is low (last release 2021). Key differentiator: enables in-process HTTP testing with Axios without network I/O, supporting both generic HTTP dispatch and Fastify applications. Requires Node >=20, axios ^1, and fastify >=4 as peer dependencies. Ships TypeScript types. Caveats include unsupported maxRedirects, socketPath, proxy, and httpAgent.

npm install axios-light-my-request-adapter
INSTALL
IMPORT
SIG · AXIOS-LIGHT-MY-REQ
A
axios-light-my-request-adapter
testingjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createLightMyRequestAdapter
import { createLightMyRequestAdapter } from 'axios-light-my-request-adapter'
const createLightMyRequestAdapter = require('axios-light-my-request-adapter').createLightMyRequestAdapter
ESM is supported; named import only. CommonJS works with require destructuring.
createLightMyRequestAdapterFromFastify
import { createLightMyRequestAdapterFromFastify } from 'axios-light-my-request-adapter'
Named import, specific for Fastify integration. Requires fastify >=4.

Creates an Axios instance with Light my Request adapter using a plain Node.js HTTP dispatch handler, then makes a GET request.

import axios from 'axios'; import { createLightMyRequestAdapter } from 'axios-light-my-request-adapter'; function dispatch(req, res) { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ data: 'Hello World!' })); } const instance = axios.create({ baseURL: 'http://localhost/', adapter: createLightMyRequestAdapter(dispatch), }); const res = await instance.get('/'); console.log(res.data);
Debug
Known issues
gotchamaxRedirects is not supported and will throw an error
fix
Avoid setting maxRedirects in Axios config; use a different approach for redirect handling.
affects: >=0.0.0
gotchasocketPath and proxy are not supported and will throw
fix
Remove socketPath or proxy from Axios config when using this adapter.
affects: >=0.0.0
gotchahttpAgent and httpsAgent are ignored silently
fix
Do not rely on custom agents; they have no effect.
affects: >=0.0.0
deprecatedRequires Node >=20; older Node versions may not work
fix
Upgrade Node.js to version 20 or later.
affects: >=0.4.0
Errors
Common errors & fixes
Error: maxRedirects is not supported by light-my-request
Axios config includes maxRedirects option, which is unsupported.
fix
Remove maxRedirects from Axios request config.
Error: socketPath is not supported by light-my-request
Axios config includes socketPath option.
fix
Remove socketPath from Axios request config.
TypeError: adapter is not a function
Incorrect import or invalid adapter value passed to axios.create.
fix
Ensure you import createLightMyRequestAdapter correctly and call it: adapter: createLightMyRequestAdapter(dispatch).
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency: adapter requires axios v1
fastifyoptionalPeer dependency: required for createLightMyRequestAdapterFromFastify helper
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
axios-light-my-request-adapter — npm install axios-light-my-request-adapter · libregistry