
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
bucket-decorator
Advanced tools
Bucket Decorator is a npm module for help you to use safe web services or other stuff without getting api limit error (Too many requests)
reflect-metadata
modulenpm install bucket-decorator
import { Bucket } from 'bucket-decorator';
class MyAwesomeClass {
...
@Bucket.Limiter({
limit: 40,
leakRate: 2,
limitKey: 'my namespace',
})
myAwesomeMethod(@Bucket.LimitKey() token){...}
...
}
You can decorate any method
Property | type | Default value | Description |
---|---|---|---|
limit | number | 100 | Maxim 'bucket' size. Method calls what 'get' into bucket are executed instantly. Other ones are in queue. |
leakRate | number | 10 | Leak rate for your bucket. Every second 'bucket' will have place for more leakRate calls. |
limitKey | string | '' | Is optional. You can have multiple 'buckets' with different 'names'. |
You can decorate any string propery of your method. This will override BucketOptionsInterface.limitKey
option
import 'reflect-metadata';
import {
Bucket
} from 'bucket-decorator';
class Test {
@Bucket.Limiter({
leakRate: 2,
limit: 40
})
doMyWork( @Bucket.LimitKey() myToken) {
console.log(`Working for ${myToken}`);
}
}
(async () => {
let testInstance = new Test();
for (let i = 0; i < 100; i++) {
await testInstance.doMyWork('my-secret-token');
}
})();
npm install
or yarn
npm run start
or yarn start
FAQs
Decorators for limiting usage of a class method
We found that bucket-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.