@bejibun/limiter
v0.1.13
Published
Limiter for Bejibun Framework
Maintainers
Readme
Limiter for Bejibun
Limiter for Bejibun Framework.
Usage
Installation
Install the package.
# Using Bun
bun add @bejibun/limiter
# Using Bejibun
bun ace install @bejibun/limiterConfiguration
The configuration file automatically executed if you are using ace.
Or
Add limiter.ts inside config directory on your project if doesn't exist.
config/limiter.tsconst config: Record<string, any> = {
limit: 60,
duration: 60 // seconds
};
export default config;You can pass the value with environment variables.
How to Use
How to use tha package.
import RateLimiter from "@bejibun/limiter";
await RateLimiter.attempt(`user:${user.id}`, 60 /* limit */, () => {
//
}, 60 /* duration (optional) */);
await RateLimiter.tooManyAttempts(`user:${user.id}`, 60 /* limit */, 60 /* duration (optional) */);
await RateLimiter.clear(`user:${user.id}`);☕ Support / Donate
If you find this project helpful and want to support it:
Or you can buy this $BJBN (Bejibun) tokens here.
