mirror of
https://github.com/directus/directus.git
synced 2026-01-13 06:57:56 -05:00
* Dangerously update API deps * Dangerously move app dependencies to pnpm-workspace * Move all dependencies to catalog * Sort catalog * Pnpm update * Use pnpm 10.14 * Update for zod breaking change * Fix unhead breaking change * Downgrade major api upgrades * Downgrade app major upgrades * Fix app tests * Downgrade isolated-vm * Add changeset * Fix template in head * Resolve unhead lang signature * Downgrade unhead * Downgrade keyv/redis It uses a different redis lib under the hood which is incompatible * Resolve import in test * Update and move workspace root dependencies * Update CSS for updated linter rules * Oops * Run formatter * Update rule name * Run prettier * Move utils peer to catalog * Add focus-trap dependency
@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.