mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Bumps [tsup](https://github.com/egoist/tsup) from 8.1.0 to 8.1.2. - [Release notes](https://github.com/egoist/tsup/releases) - [Changelog](https://github.com/egoist/tsup/blob/dev/.releaserc.json) - [Commits](https://github.com/egoist/tsup/compare/v8.1.0...v8.1.2) --- updated-dependencies: - dependency-name: tsup dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@directus/pressure
Pressure based rate limiter
Description
This package exports a pressure based rate limiter that is used within Directus, an open-source headless CMS.
For more information about Directus, visit the official website.
Installation
npm install @directus/pressure
Usage
Standalone
The pressure monitor is a class that can be used anywhere:
import { PressureMonitor } from '@directus/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 '@directus/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.