{"id":45526,"library":"nest-ratelimiter","title":"NestJS Rate Limiter","description":"A distributed, consistent rate limiter for NestJS backed by Redis, designed for high-traffic applications. Version 0.4.0 uses Lua scripts for atomic operations with configurable limits (max, duration) via decorators or guards. Integrates with `nestjs-redis` or `ioredis`. Stable, actively maintained with support for NestJS 8–11. Compared to `nestjs-rate-limiter`, this package offers Lua-based atomicity and flexible Redis integration.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/iamolegga/nestjs-ratelimiter","tags":["javascript","nest","nestjs","nest.js","rate","ratelimit","ratelimiter","limit","limiter","typescript"],"install":[{"cmd":"npm install nest-ratelimiter","lang":"bash","label":"npm"},{"cmd":"yarn add nest-ratelimiter","lang":"bash","label":"yarn"},{"cmd":"pnpm add nest-ratelimiter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"human-readable time durations","package":"ms","optional":false},{"reason":"core rate limiting logic (generic Redis-based)","package":"ratelimiter","optional":false},{"reason":"NestJS framework core","package":"@nestjs/core","optional":false},{"reason":"NestJS common utilities","package":"@nestjs/common","optional":false},{"reason":"TypeScript type definitions for ratelimiter","package":"@types/ratelimiter","optional":true}],"imports":[{"note":"Named export, not default.","wrong":"import RateLimiterModule from 'nest-ratelimiter';","symbol":"RateLimiterModule","correct":"import { RateLimiterModule } from 'nest-ratelimiter';"},{"note":"ESM-only since v0.4.0 (Node >=18).","wrong":"const { RateLimit } = require('nest-ratelimiter');","symbol":"RateLimit","correct":"import { RateLimit } from 'nest-ratelimiter';"},{"note":"All exports are from the main package.","wrong":"import { RateLimiterGuard } from 'nest-ratelimiter/guards';","symbol":"RateLimiterGuard","correct":"import { RateLimiterGuard } from 'nest-ratelimiter';"}],"quickstart":{"code":"// app.module.ts\nimport { Module } from '@nestjs/common';\nimport { RateLimiterModule } from 'nest-ratelimiter';\n\n@Module({\n  imports: [\n    RateLimiterModule.register({\n      for: 'Microservice', // or 'Web'\n      redis: {\n        host: process.env.REDIS_HOST || 'localhost',\n        port: Number(process.env.REDIS_PORT) || 6379,\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n\n// controller.ts\nimport { Controller, Get, UseGuards } from '@nestjs/common';\nimport { RateLimit, RateLimiterGuard } from 'nest-ratelimiter';\n\n@Controller()\n@UseGuards(RateLimiterGuard)\nexport class AppController {\n  @Get()\n  @RateLimit({ max: 10, duration: 60000 }) // 10 requests per minute\n  getHello(): string {\n    return 'Hello!';\n  }\n}","lang":"typescript","description":"Shows module registration with Redis config and rate limiting on a route with 10 requests per minute limit."},"warnings":[{"fix":"Use `import` syntax and Node >=18.","message":"ESM-only import; requires Node >=18","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Apply `@UseGuards(RateLimiterGuard)` at the controller or module level.","message":"Rate limit is enforced per route, not globally by default. Use guard globally to apply to all routes.","severity":"gotcha","affected_versions":"*"},{"fix":"Check documentation; no breaking change but understand the difference.","message":"The `for: 'Microservice'` option uses Redis List, `'Web'` uses Redis Sorted Set. Different implementations.","severity":"deprecated","affected_versions":"<0.4.0"},{"fix":"Ensure Redis is available or handle connection errors.","message":"Must have Redis running; no fallback. If Redis is down, rate limiting fails.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade Node to 18+.","message":"Minimum Node.js version is 18.0.0 starting from v0.4.0.","severity":"breaking","affected_versions":">=0.4.0"}],"env_vars":null,"search_vec":"'0.4.0':21 '11':52 '8':51 'activ':45 'applic':19 'atom':26,65 'back':11 'base':64 'compar':53 'configur':29 'consist':6 'decor':34 'design':14 'distribut':5 'durat':32 'flexibl':67 'guard':36 'high':17 'high-traff':16 'integr':37,69 'ioredi':43 'javascript':70 'limit':3,8,30,58,77,78 'lua':23,63 'lua-bas':62 'maintain':46 'max':31 'nest':71 'nest.js':73 'nestj':1,10,40,50,56,72 'nestjs-rate-limit':55 'nestjs-redi':39 'offer':61 'oper':27 'packag':60 'rate':2,7,57,74 'ratelimit':75,76 'redi':13,41,68 'script':24 'stabl':44 'support':48 'traffic':18 'typescript':79 'use':22 'version':20 'via':33","created_at":"2026-06-07T12:55:27.176958+00:00","updated_at":"2026-06-07T12:55:27.176958+00:00","problems":[{"fix":"Run `npm install nest-ratelimiter` and ensure tsconfig.json includes 'node_modules' or 'esModuleInterop'.","cause":"Missing package installation or wrong import path.","error":"Cannot find module 'nest-ratelimiter' or its corresponding type declarations."},{"fix":"Use `@RateLimit()` decorator only, or ensure the guard is used in an HTTP context.","cause":"Using RateLimiterGuard in a non-HTTP context (e.g., Microservice) without proper decorator.","error":"RateLimiterGuard requires an HTTP context. Are you in a web context?"},{"fix":"Update ratelimiter and redis packages to latest compatible versions.","cause":"Redis Lua script argument mismatch (rare, possibly due to version incompatibility).","error":"ERR wrong number of arguments for 'eval' command"},{"fix":"Ensure module is imported with `.register({for: 'Web', redis: {...}})`.","cause":"RateLimiterModule.register() not called or missing 'redis' config.","error":"TypeError: Cannot read properties of undefined (reading 'set')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/iamolegga/nestjs-ratelimiter#readme","github":"https://github.com/iamolegga/nestjs-ratelimiter","docs":null,"changelog":null,"pypi":null,"npm":"nest-ratelimiter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}