{"id":46400,"library":"smart-request-queue","title":"Smart Request Queue","description":"Enterprise-grade request queue for NestJS with Redis support, retries, priorities, and rate limiting. Current stable version is 1.2.1, released under MIT license. This package provides a NestJS module for managing request queues with features like rate limiting per queue, per-key isolation, priority-based execution, retry with exponential backoff, job timeout handling, and cancelation. It supports both in-memory (default) and Redis-backed storage for persistence and distributed events across nodes via Redis Pub/Sub. Key differentiators include typed event streams via RxJS Observable, queue introspection, and support for both function-based and Axios-based jobs. Requires NestJS 9+, reflect-metadata, and rxjs 7+. Ships with TypeScript types and supports dynamic/async module configuration. Suitable for production scenarios where throttling, job queuing, and rate limiting are needed within a NestJS application.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/VaheHak/smart-request-queue","tags":["javascript","nestjs","queue","rate-limit","throttling","bottleneck","redis","job-queue","task-queue","typescript"],"install":[{"cmd":"npm install smart-request-queue","lang":"bash","label":"npm"},{"cmd":"yarn add smart-request-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add smart-request-queue","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for NestJS module decorators and DI","package":"@nestjs/common","optional":false},{"reason":"Peer dependency required for NestJS module system","package":"@nestjs/core","optional":false},{"reason":"Peer dependency required for NestJS reflection","package":"reflect-metadata","optional":false},{"reason":"Peer dependency required for Observable-based event streams","package":"rxjs","optional":false}],"imports":[{"note":"ESM-only since v1.0; CommonJS require still works but import is preferred.","wrong":"const QueueModule = require('smart-request-queue').QueueModule;","symbol":"QueueModule","correct":"import { QueueModule } from 'smart-request-queue';"},{"note":"Direct internal path imports are not supported; always import from the package root.","wrong":"import { QueueService } from 'smart-request-queue/dist/queue.service';","symbol":"QueueService","correct":"import { QueueService } from 'smart-request-queue';"},{"note":"QUEUE_EVENTS is a named export, not a default export.","wrong":"import QUEUE_EVENTS from 'smart-request-queue';","symbol":"QUEUE_EVENTS","correct":"import { QUEUE_EVENTS } from 'smart-request-queue';"}],"quickstart":{"code":"import { Module } from '@nestjs/common';\nimport { QueueModule, QueueService } from 'smart-request-queue';\n\n@Module({\n  imports: [\n    QueueModule.forRoot({\n      requests: [\n        { name: 'api', requestsCount: 5, requestInterval: '1sec' },\n      ],\n    }),\n  ],\n  providers: [MyService],\n})\nexport class AppModule {}\n\n@Injectable()\nexport class MyService {\n  constructor(private readonly queue: QueueService) {}\n\n  async doSomething() {\n    const result = await this.queue.add({\n      name: 'api',\n      fn: async () => 'Task completed',\n      priority: 1,\n    });\n    console.log(result);\n  }\n}","lang":"typescript","description":"Basic NestJS module setup with in-memory queue and a service that adds a job to the 'api' queue with priority."},"warnings":[{"fix":"Use ES module imports (import { ... } from 'smart-request-queue') in TypeScript or Node ESM mode.","message":"As of version 1.0.0, package is ESM-only. CommonJS require may still work in Node >=16 but is not officially supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update imports to the new API; refer to v1 migration guide.","message":"In version 0.x, the module was imported as QueueModule.forRootAsync({...}) with different options. As of 1.0, use forRoot or forRootAsync with the new options shape.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Check Redis connectivity and credentials. Use environment variables for configuration.","message":"When using Redis storage, ensure Redis server is running and the redisOptions are correct. Failure to connect will cause queue operations to throw until the connection is re-established.","severity":"gotcha","affected_versions":"all"},{"fix":"Use only one of 'axios' or 'fn' per job.","message":"The 'axios' and 'fn' options in QueueJob are mutually exclusive. Providing both will cause the fn to be ignored or an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Always provide a 'key' when per-user/per-tenant isolation is required.","message":"The 'key' option for isolation must be provided consistently across related jobs. Missing key means no isolation, which may unintendedly share rate limits.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.2.1':23 '7':115 '9':109 'across':79 'applic':141 'axio':104 'axios-bas':103 'back':72 'backoff':56 'base':51,101,105 'bottleneck':149 'cancel':61 'configur':124 'current':19 'default':68 'differenti':85 'distribut':77 'dynamic/async':122 'enterpris':5 'enterprise-grad':4 'event':78,88 'execut':52 'exponenti':55 'featur':39 'function':100 'function-bas':99 'grade':6 'handl':59 'in-memori':65 'includ':86 'introspect':94 'isol':48 'javascript':142 'job':57,106,131,152 'job-queu':151 'key':47,84 'licens':27 'like':40 'limit':18,42,135,147 'manag':35 'memori':67 'metadata':112 'mit':26 'modul':33,123 'need':137 'nestj':10,32,108,140,143 'node':80 'observ':92 'packag':29 'per':43,46 'per-key':45 'persist':75 'prioriti':15,50 'priority-bas':49 'product':127 'provid':30 'pub/sub':83 'queu':132 'queue':3,8,37,44,93,144,153,156 'rate':17,41,134,146 'rate-limit':145 'redi':12,71,82,150 'redis-back':70 'reflect':111 'reflect-metadata':110 'releas':24 'request':2,7,36 'requir':107 'retri':14,53 'rxjs':91,114 'scenario':128 'ship':116 'smart':1 'stabl':20 'storag':73 'stream':89 'suitabl':125 'support':13,63,96,121 'task':155 'task-queu':154 'throttl':130,148 'timeout':58 'type':87,119 'typescript':118,157 'version':21 'via':81,90 'within':138","created_at":"2026-06-07T12:59:44.498692+00:00","updated_at":"2026-06-07T12:59:44.498692+00:00","problems":[{"fix":"Run npm install smart-request-queue and ensure it's in package.json dependencies.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'smart-request-queue'"},{"fix":"Inject via constructor: constructor(private queue: QueueService) {}","cause":"Attempting to use QueueService as a function instead of injecting as a provider.","error":"QueueService is not a function"},{"fix":"Add the queue name to the requests array in the module configuration.","cause":"The queue name used in add() does not match any queue defined in QueueModule.forRoot().","error":"Error: Queue 'api' not configured"},{"fix":"Make sure QueueModule is imported in your module and that the service using QueueService is in the same module context.","cause":"QueueService is undefined because it was not provided in the module.","error":"TypeError: Cannot read properties of undefined (reading 'add')"}],"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/VaheHak/smart-request-queue#readme","github":"https://github.com/VaheHak/smart-request-queue","docs":null,"changelog":null,"pypi":null,"npm":"smart-request-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}