
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
ts-mongo-queue
Advanced tools
A TypeScript library for managing queues using MongoDB.
Any developer who needs mongodb-queue with support to mongodb-7 and node driver 6.0.1.
Marcus Yoda @marcusyoda
npm install ts-mongo-queue
Or with Yarn:
yarn add ts-mongo-queue
First, import the necessary functions and classes:
import { MongoClient } from 'mongodb'
import { MongoQueue } from 'ts-mongo-queue'
Next, create an instance of MongoQueue
:
const client = new MongoClient('your_mongodb_connection_string')
const queue = MongoQueue(client, 'your_queue_name')
const payload = { data: 'test' }
const result = await queue.add(payload)
console.log(result.messageId)
const nextMessage = await queue.get()
console.log(nextMessage.payload)
Certainly! I'll enhance the "Configuration" section based on the initial information you provided about the library.
ts-mongo-queue
provides a range of configurations to tailor the queue to your specific needs. When creating a new instance of MongoQueue
, you can provide an optional opts
object to configure the behavior:
const queue = MongoQueue(client, 'your_queue_name', {
visibility: 30,
delay: 10,
deadQueue: new Queue(client, 'dead_queue_name'),
maxRetries: 5,
})
visibility: The duration (in seconds) a message remains hidden from get
after being fetched, providing the consumer a window to process and delete the message. Defaults to 30
seconds.
delay: The duration (in seconds) a message waits before becoming visible for the first time. Useful for scheduled jobs or delayed processing. Defaults to no delay.
deadQueue: An optional instance of another Queue
where messages that exceed the maxRetries
count are moved. If not provided, messages that fail repeatedly will remain in the primary queue.
maxRetries: The maximum number of attempts to fetch a message before it's considered dead and, if a deadQueue
is provided, moved there. Defaults to infinite retries.
Some configurations can also be set using environment variables:
500
.For setting the environment variable:
export QUEUE_GET_RECURSION_LIMIT=1000
The library is fully tested. To run tests:
yarn test
Feel free to open issues or pull requests if you'd like to improve or fix something in the library!
MIT
FAQs
mongo-queue typescript implementation
The npm package ts-mongo-queue receives a total of 143 weekly downloads. As such, ts-mongo-queue popularity was classified as not popular.
We found that ts-mongo-queue 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
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.