# express-ddos-protector

> # Bucket strategy

Latest version **1.0.1** (published 2020-06-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install express-ddos-protector
pnpm add express-ddos-protector
yarn add express-ddos-protector
bun add express-ddos-protector
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-23 |
| First published | 2020-06-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | lawrence1470 |

## Links

- npm: https://www.npmjs.com/package/express-ddos-protector
- npm.io page: https://npm.io/package/express-ddos-protector

## Recent versions

- 1.0.1 (latest) — 2020-06-23
- 1.0.0 — 2020-06-23

## README

# DDOS_protector

# Bucket strategy

## Protects Api from malicious users.

### To use this npm package please do \$npm i bucket-ddos

### import the npm package

#### const Limiter = require('express-bucket-rate-limiter');

### This package works as a callback function, to use it please refer to this example.

```javascript
const express = require('express');
const Limiter = require('express-ddos-protector');
const limit = new Limiter();
const app = express();
const port = 3000;

// Apply to all requests
app.get('/', limit.limitRequests(1, 2, 1000), (req, res) => {
	const Blacklist = limit.Blacklist;
	if (Blacklist.includes(req.ip)) {
		res.send('access denied');
	} else {
		res.send('hello world');
	}
});

app.listen(port, () => console.log(`Example app listening on port ${port}!`));
```

## limiter function takes in three parameters (perSecond, maxReq, timeInMs)

## perSecond represents how fast you are filling the bucket per second

## maxReq represents the max amount of req a bucket can hold.

### In the above example I am filling the bucket once per second. If the user depletes the bucket quicker than it can fill up than he will be inserted in a blackList array. The bucket size in this example is two and I am filling the bucket once every 1000 ms (1 second)

[Github Link](https://github.com/lawrence14701/express-ddos-protector)

---
_Source: https://npm.io/package/express-ddos-protector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
