Socket
Book a DemoInstallSign in
Socket

express-chaos-middleware

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-chaos-middleware

Put some chaos in your express application

1.2.4
latest
Source
npmnpm
Version published
Weekly downloads
283
-47.69%
Maintainers
1
Weekly downloads
 
Created
Source

express-chaos-middleware

Put some chaos in your express application.

Description

The aim of this library is to provide simple chaos testing cases for express applications.

Installation

npm add express-chaos-middleware

Features

  • Requests slowdown : Endpoints can be slowed down randomly
  • Random response error : Endpoints can respond randomly with an error code
  • Random exception : Endpoints can throw exceptions randomly
  • Seeding : Manage random to replay scenarios

Chaos features have a 10 percent "chance" of being called by default. The percentage can be changed in the configuration object.

Usage

Simple usage

const {chaos} = require('express-chaos-middleware');

app.use(chaos())

Use an existing seed

The random seed can be configured in the input object param.

const {chaos} = require('express-chaos-middleware');

app.use(chaos({
  // this seed throw an exception on the first call
  seed: 'uJaK8BUr2084pph',
}))

Advanced usage - Change chaos probability

The probability of chaos can be configured in the input object param.

This parameter is a number value between 0 and 100.

const {chaos} = require('express-chaos-middleware');

app.use(chaos({
  probability: 50,
}))

Advanced usage - Override max delay

The max slowdown delay can be configured in the input object param.

const {chaos} = require('express-chaos-middleware');

app.use(chaos({
  maxDelay: 1000,
}))

Advanced usage - Use custom http error codes array

The http error codes array can be overridden in the input object param.

const {chaos} = require('express-chaos-middleware');

app.use(chaos({
  errCodes: [400, 500],
}))

Advanced usage - Use custom feature list

The chaos feature list can be overridden in the input object param.

You can for example only use delay and http error codes with the following configuration

All rules are exported in the Rules object.

const {chaos} = require('express-chaos-middleware');

app.use(chaos({
  rules: [Rules.DELAY, Rules.HTTPERROR],
}))

Keywords

express

FAQs

Package last updated on 05 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.