1.0.0 • Published 3 years ago

express-faulty v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

express-faulty

express-faulty simulates faults in your Express.js web applications.

Why?

Applications will fail. An overloaded service due to high traffic spike or a degraded system that your service depends on. This module aims to simulate these faults to help create demo applications showing the issues and techniques for handling these issues.

Installation

npm install express-faulty

Features

  • Service going down
  • Service degradation

Quickstart

Service Down

const express = require('express')
const faulty = require('express-faulty')
const app = express()

const faultyMiddleware = faulty({
    enabled: true,
    faultType: 'DOWN',
    afterRequestCount: 5
})

app.get('/', faultyMiddleware, (req, res) => {
    res.send('Hello World!')
})

app.listen(3000, () => {
    console.log('Starting faulty application...')
})
PropertyDescriptionDefault
enabledEnables or disables the faulttrue
faultTypeThe fault type. Supported: DOWN and DEGRADATIONDOWN
afterRequestCountApply the fault after N requests0

Service Degradation

const express = require('express')
const faulty = require('express-faulty')
const app = express()

const faultyMiddleware = faulty({
    enabled: true,
    faultType: 'DEGRADATION',
    initialLatencyInMs: 300,
    increaseLatencyPerRequestInMs: 100,
    afterRequestCount: 3
})

app.get('/', faultyMiddleware, (req, res) => {
    res.send('Hello Faulty!')
})

app.listen(3000, () => {
    console.log('Starting faulty application...')
})
PropertyDescriptionDefault
enabledEnables or disables the faulttrue
faultTypeThe fault type. Supported: DOWN and DEGRADATIONDOWN
initialLatencyInMsThe initial latency in milliseconds0
increaseLatencyPerRequestInMsIncrease of latency after each request in millisecondsDOWN
afterRequestCountApply the fault after N requests0