Skip to content

arxja/job-queue-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

76 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

JetQueue

Packages โ€ข Examples โ€ข API

TypeScript Bun Node.js SQLite


๐Ÿค” What is JetQueue?

JetQueue is a background job processing system that lets you move heavy work out of your API's request/response cycle. Instead of making users wait 10 seconds for an email to send, you queue it and respond instantly.

The Problem:

// โŒ Without a queue - user waits 5+ seconds
app.post("/signup", async (req, res) => {
  await createUser(req.body); // 100ms
  await sendWelcomeEmail(); // 2000ms
  await generateThumbnail(); // 3000ms
  res.json({ ok: true }); // User waited 5.1 seconds
});

The Solution:

// โœ… With JetQueue - user waits 100ms
app.post("/signup", async (req, res) => {
  await createUser(req.body); // 100ms
  queue.add("send-welcome-email", { data: req.body });
  queue.add("generate-thumbnail", { data: req.body });
  res.json({ ok: true }); // User waited 100ms!
});

โœจ Features

  • Concurrent Processing - Run N jobs simultaneously
  • Auto-Retry - Exponential, linear, or fixed backoff strategies
  • Priority Queues - Critical jobs jump the line
  • Delayed & Recurring Jobs - Schedule work for later
  • Persistent Storage - SQLite for durability, in-memory for speed
  • Real-time Events - WebSocket updates for live monitoring
  • CLI Dashboard - Monitor queues right in your terminal
  • Web Dashboard - Next.js monitoring UI
  • REST API - Use from any language, not just TypeScript
  • Zero Dependencies - Core library has no external dependencies

๐Ÿ“ฆ Packages

package description npm
@jet-queue/core Core queue engine https://img.shields.io/npm/v/@jet-queue/core
@jet-queue/server REST API + WebSocket server https://img.shields.io/npm/v/@jet-queue/server
@jet-queue/client TypeScript SDK for the server https://img.shields.io/npm/v/@jet-queue/client
@jet-queue/cli Terminal dashboard https://img.shields.io/npm/v/@jet-queue/cli
@jet-queue/dashboard Terminal dashboard https://img.shields.io/npm/v/@jet-queue/dashboard

๐Ÿš€ Quick Start

Option 1: Library Only (Simplest)

npm install @jet-queue/core
import { JetQueue } from "@jet-queue/core";

const queue = new JetQueue({ concurrency: 5 });

// Add jobs
queue.add(async () => {
  await sendEmail("user@test.com");
});

// Monitor
queue.on("job:completed", ({ job, duration }) => {
  console.log(`Job ${job.name} done in ${duration}ms`);
});

// Get stats
console.log(queue.getState());
// { pending: 0, running: 1, completed: 42, failed: 2 }

Option 2: Full Server + SDK

# Start the server
npx @jet-queue/server --port 3001 --db ./queue.db

# In your app
npm install @jet-queue/client
import { JetQueueClient } from "@jet-queue/client";

const client = new JetQueueClient({ baseUrl: "http://localhost:3001" });

// Add a job
const job = await client.addJob("send-email", {
  data: { to: "user@test.com" },
  priority: "high",
});

// Wait for it to complete (real-time)
client.onJobCompleted(job.id, (job) => {
  console.log("Email sent!", job.result);
});

๐Ÿ—๏ธ Architecture

flowchart TD
    A["<b>Your Application</b><br><code>import { JetQueueClient } from '@jet-queue/client'</code>"]

    B["<b>@jet-queue/server</b><br><i>Hono + Bun</i><br><br>๐Ÿ“ฎ POST /api/jobs - Add jobs<br>๐Ÿ” GET /api/jobs/:id - Check status<br>๐Ÿ”Œ WS /ws - Real-time events"]

    C["<b>@jet-queue/core</b><br><br>๐Ÿ“ฆ JetQueue Engine<br>โ”œโ”€โ”€ โšก Concurrency Control<br>โ”œโ”€โ”€ ๐Ÿ“Š Priority Queue<br>โ”œโ”€โ”€ ๐Ÿ”„ Retry Logic<br>โ”œโ”€โ”€ ๐Ÿ’พ SQLite Persistence<br>โ””โ”€โ”€ ๐Ÿ“ก Event System"]

    A -->|HTTP + WebSocket| B
    B --> C

    style A fill:#bbdefb,stroke:#1976d2,stroke-width:2px,color:#000
    style B fill:#ffe0b2,stroke:#f57c00,stroke-width:2px,color:#000
    style C fill:#e1bee7,stroke:#7b1fa2,stroke-width:2px,color:#000
Loading

๐Ÿ“Š Use Cases

Industry Examples
E-commerce Order confirmation emails, inventory sync, invoice PDF generation
Social Media Image/video processing, notification dispatch, feed generation
SaaS Report generation, data exports, search indexing, billing
AI/ML Model inference, data preprocessing, batch predictions
IoT Sensor data processing, device command queues

๐Ÿ”ง Configuration

const queue = new JetQueue({
  concurrency: 5,          // Max simultaneous jobs
  maxQueuedJobs: 10000,    // Refuse when queue is full
  autoStart: true,         // Start processing immediately
  defaultJobOptions: {
    priority: 'normal',
    timeout: 30000,        // 30 seconds
    maxAttempts: 3,        // Retry up to 3 times
    retryOptions: {
      strategy: 'exponential',
      delay: 1000,         // Start at 1 second
      maxDelay: 60000,     // Cap at 1 minute
    },
  },
});

๐Ÿ› ๏ธ Built With

  • TypeScript - Type safety everywhere
  • Bun - Fast runtime, built-in test runner, SQLite
  • Hono - Lightweight, fast HTTP framework
  • Next.js - Web dashboard
  • Ink - React for CLI
  • SQLite - Zero-config persistence

๐Ÿ“š Documentation

๐Ÿค Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

MIT ยฉ Arash Jafari 2026

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages