npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

badger-mq-lite

v1.2.4

Published

A simple pluggable messaging queue (memory, file, sqlite)

Readme

📦 Badger MQ Lite

A lightweight, pluggable message queue library for Node.js with multiple storage adapters (memory, file, sqlite).

Useful for learning, prototyping, and small-scale applications where you want to implement background processing, task scheduling, or job queues without relying on heavy external brokers like RabbitMQ or Kafka.


✨ Features

  • 🔌 Multiple Adapters – switch between memory, file, and sqlite storage
  • 🛠 Simple API – create, list, delete queues and send/receive messages
  • 💾 Persistence – use file or sqlite adapters for persistent storage
  • 🚀 Pluggable – extend with your own storage adapter easily
  • 🧪 Great for learning queues and testing queue-driven architectures

📦 Installation

npm install badger-mq-lite

For SQLite support, also install:

npm install sqlite sqlite3

🚀 Quick Start

1. Import the library

import { queue } from "badger-mq-lite";

2. Select an adapter

You can choose one of:

  • queue.memory → in-memory queue (volatile, cleared when process restarts)
  • queue.file → file-based storage (persistent)
  • queue.sqlite → SQLite database storage (persistent)

Example with SQLite:

import { queue } from "badger-mq-lite";

const mq = queue.sqlite;

// Create a queue
await mq.createQueue("emailQueue");

// Send a message
await mq.sendMessage("emailQueue", { to: "[email protected]", subject: "Welcome!" });

// Receive messages
const messages = await mq.receiveMessages("emailQueue");

// Ack messages
const messages = await mq.ackMessage("emailQueue", "message-id");

// Delete all acked messages
const messages = await mq.purgeQueue("emailQueue", "message-id");

// Move messages to DLQ
const messages = await mq.moveToDeadLetterQueue("emailQueue", "message-id");

// Delete a queue
await mq.deleteQueue("emailQueue");

🔧 API Reference

createQueue(queueName: string): Promise<void>

Creates a new queue with the given name.

listQueues(): Promise<string[] | object>

Lists all existing queues.

  • Memory/File → returns an array of queue names.
  • SQLite → returns an object of queues.

deleteQueue(queueName: string): Promise<void>

Deletes a queue and its messages.

sendMessage(queueName: string, body: any): Promise<void>

Sends a message into the queue. body can be any serializable object.

receiveMessages(queueName: string): Promise<any[]>

Retrieves messages from the queue.

ackMessage(queueName: string, messageId: string): Promise<any[]>

Acknowlege a message


⚙️ Adapters

1. Memory Adapter

  • Fast, volatile
  • Good for testing & dev
const mq = queue.memory;

2. File Adapter

  • Stores queues/messages in JSON files
  • Persistent across restarts
  • Great for small-scale persistence
const mq = queue.file;

3. SQLite Adapter

  • Stores queues/messages in SQLite database
  • Best persistence option for production-like testing
const mq = queue.sqlite;

🧩 Writing Your Own Adapter

Each adapter must implement these methods:

{
  createQueue(queueName),
  listQueues(),
  deleteQueue(queueName),
  sendMessage(queueName, body),
  ackMessage(queueName, messageId),
  purgeQueue(queueName, messageId),
  moveToDeadLetterQueue(queueName, messageId),
  receiveMessage(queueName),
  getMessages(queueName),
  purgeQueue(queueName)
}

This makes it easy to add support for other databases like MongoDB, PostgreSQL, Redis.


💡 Use Cases

  • Background job processing
  • Task scheduling
  • Worker queue for API requests
  • Learning message queue patterns

📜 License

MIT © 2025 AmazingMax