@clairview/pressure
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@clairview/pressure

Pressure based rate limiter

Description

This package exports a pressure based rate limiter that is used within Clairview, an open-source headless CMS.

For more information about Clairview, visit the official website.

Installation

npm install @clairview/pressure

Usage

Standalone

The pressure monitor is a class that can be used anywhere:

import { PressureMonitor } from '@clairview/pressure';

const monitor = new PressureMonitor({
	maxEventLoopUtilization: 0.8,
});

monitor.overloaded; // true | false

Express

The library also exports an express middleware that can be used to throw an Error when the pressure monitor reports overloaded:

import express from 'express';
import { handlePressure } from '@clairview/pressure';

const app = express();

app.use(
	handlePressure({
		maxEventLoopUtilization: 0.8,
	}),
);

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Additional Resources

Readme

Keywords

none

Package Sidebar

Install

npm i @clairview/pressure

Homepage

clairview.io

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

6.56 kB

Total Files

5

Last publish

Collaborators

  • clairview