https://github.com/anibalalpizar/api-stress
đŠī¸ Middleware to simulate network conditions in APIs
https://github.com/anibalalpizar/api-stress
api express http-errors latency middleware nodejs npm-package packet-loss resilience typescript
Last synced: about 2 months ago
JSON representation
đŠī¸ Middleware to simulate network conditions in APIs
- Host: GitHub
- URL: https://github.com/anibalalpizar/api-stress
- Owner: anibalalpizar
- License: mit
- Created: 2024-12-11T05:04:25.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-12-11T07:51:43.000Z (10 months ago)
- Last Synced: 2025-08-09T01:34:25.183Z (2 months ago)
- Topics: api, express, http-errors, latency, middleware, nodejs, npm-package, packet-loss, resilience, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/api-stress
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 đ§
```bash
npm install api-stress
```## Usage đ
```typescript
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 delays
- `packetLoss`: Simulate percentage of dropped packets
- `errorSimulation`: Inject random HTTP errors## License đ
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contributing đ¤
Contributions are welcome! Feel free to submit a PR or open an issue.