1.0.0 âĸ Published 7 months ago
api-stress v1.0.0
API Storm Tester đŠī¸
Overview đ
api-stress
is a middleware for simulating various network conditions in Node.js applications to test API resilience. It can simulate random network latency, packet loss, and HTTP errors.
Features â¨
- Random network latency simulation
- Packet loss simulation
- HTTP error injection
- Configurable network storm parameters
Installation đ§
npm install api-stress
Usage đ
import express from "express";
import { StormMiddleware } from "api-stress";
const app = express();
// Create Storm Middleware instance with aggressive network simulation
const stormMiddlewareInstance = new StormMiddleware({
delay: { min: 500, max: 2000 },
packetLoss: { rate: 10 },
errorSimulation: {
probability: 0.05,
statusCode: 500,
message: "Simulated Internal Server Error",
},
});
// Apply storm middleware to all routes
app.use(stormMiddlewareInstance.middleware);
app.get("/test", (req, res) => {
res.json({
message: "Survived the network storm!",
});
});
Configuration Options âī¸
latency
: Simulate random network delayspacketLoss
: Simulate percentage of dropped packetserrorSimulation
: Inject random HTTP errors
License đ
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing đ¤
Contributions are welcome! Feel free to submit a PR or open an issue.
1.0.0
7 months ago