nestjs-rate-limiter
Advanced tools
Comparing version 2.6.1-alpha to 2.6.5
@@ -28,4 +28,3 @@ "use strict"; | ||
maxQueueSize: 100, | ||
errorMessage: 'Rate limit exceeded', | ||
limiterKey: undefined | ||
errorMessage: 'Rate limit exceeded' | ||
}; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const common_1 = require("@nestjs/common"); | ||
exports.RateLimit = (options) => common_1.SetMetadata('rateLimit', options); | ||
const RateLimit = (options) => common_1.SetMetadata('rateLimit', options); | ||
exports.RateLimit = RateLimit; |
@@ -163,3 +163,3 @@ "use strict"; | ||
const rateLimiter = yield this.getRateLimiter(reflectedOptions); | ||
const key = this.spesificOptions.limiterKey || request.ip.replace(/^.*:/, ''); | ||
const key = request.ip.replace(/^.*:/, ''); | ||
yield this.responseHandler(response, key, rateLimiter, points, pointsConsumed); | ||
@@ -192,3 +192,3 @@ return next.handle(); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.spesificOptions.for === 'Fastify' || this.spesificOptions.for === 'FastifyGraphql') { | ||
if (this.options.for === 'Fastify' || this.options.for === 'FastifyGraphql') { | ||
try { | ||
@@ -195,0 +195,0 @@ if (((_a = this.spesificOptions) === null || _a === void 0 ? void 0 : _a.queueEnabled) || this.options.queueEnabled) |
@@ -28,3 +28,2 @@ import { Provider } from '@nestjs/common'; | ||
errorMessage?: string; | ||
limiterKey?: string; | ||
} | ||
@@ -31,0 +30,0 @@ export interface RateLimiterOptionsFactory { |
{ | ||
"name": "nestjs-rate-limiter", | ||
"version": "2.6.1-alpha", | ||
"version": "2.6.5", | ||
"description": "Highly configurable rate limiter library", | ||
@@ -31,5 +31,5 @@ "repository": { | ||
"scripts": { | ||
"prebuild": "rm -rf dist", | ||
"build": "tsc -p tsconfig.json", | ||
"lint": "prettier --write lib" | ||
"build": "rm -rf dist && tsc -p tsconfig.json", | ||
"lint": "prettier --write lib", | ||
"test": "jest --config ./jest.config.js" | ||
}, | ||
@@ -42,3 +42,5 @@ "dependencies": { | ||
"@nestjs/core": "latest", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.11.1", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.1.1", | ||
@@ -48,4 +50,5 @@ "reflect-metadata": "0.1.13", | ||
"ts-node": "^9.0.0", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.0.2" | ||
} | ||
} |
@@ -51,2 +51,3 @@ <p align="center"> | ||
- [TODO List](https://github.com/ozkanonur/nestjs-rate-limiter#todo) | ||
- [Examples](https://github.com/ozkanonur/nestjs-rate-limiter/examples/README.md) | ||
@@ -138,3 +139,3 @@ # Description | ||
@RateLimit({ points: 1, duration: 60, errorMessage: 'Accounts cannot be created more than once in per minute' }) | ||
@RateLimit({ keyPrefix: 'sign-up', points: 1, duration: 60, errorMessage: 'Accounts cannot be created more than once in per minute' }) | ||
@Get('/signup') | ||
@@ -423,10 +424,2 @@ public async signUp() { | ||
#### ● limiterKey | ||
<code> Default: Client's Ip Address </code> | ||
<br> | ||
<code> Type: string</code> | ||
<br> | ||
limiterKey option allows you to control scenarios such as applying rate limiter based on User Account instead of Ip Address | ||
# Benchmarks | ||
@@ -433,0 +426,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
52253
23
628
0
11
445