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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@othmane_lamrani_alaoui/queue-as-a-service

v1.0.0

Published

TypeScript Queue as a Service SDK with Redis backend

Readme

@medeclipse/queue-as-a-service

Un SDK TypeScript simple et puissant pour la gestion de files d'attente avec Redis/Upstash.

Installation

npm install @medeclipse/queue-as-a-service

Configuration rapide

import { createQueue } from '@medeclipse/queue-as-a-service';

const queue = createQueue({
  redisUrl: process.env.UPSTASH_REDIS_REST_URL!,
  redisToken: process.env.UPSTASH_REDIS_REST_TOKEN!,
  queueName: 'my-queue'
});

Utilisation de base

1. Ajouter des jobs

// Job simple
const job = await queue.addJob({
  userId: 123,
  action: 'send_email'
});

// Job avec priorité (plus élevé = plus prioritaire)
await queue.addJob(data, { priority: 10 });

// Job différé (5 secondes)
await queue.addJob(data, { delay: 5000 });

// Job avec ID personnalisé
await queue.addJob(data, { jobId: 'custom-id' });

2. Traitement des jobs

// Traitement automatique avec worker
await queue.processJobs(async (job) => {
  console.log('Processing:', job.data);

  // Votre logique métier ici
  if (job.data.action === 'send_email') {
    await sendEmail(job.data.userId);
    return { success: true };
  }

  return { success: false, error: 'Unknown action' };
}, {
  concurrency: 3,        // 3 jobs en parallèle
  pollingInterval: 1000  // Vérifier toutes les secondes
});

3. Traitement manuel

// Récupérer le prochain job
const job = await queue.processNextJob();

if (job) {
  try {
    // Traiter le job
    const result = await processJob(job.data);

    // Marquer comme terminé
    await queue.completeJob(job.id, result);
  } catch (error) {
    // Marquer comme échoué
    await queue.failJob(job.id, error.message);
  }
}

4. Monitoring

// Statistiques de la queue
const stats = await queue.getStats();
console.log(stats); // { waiting: 5, active: 2, completed: 100, failed: 3, delayed: 1 }

// Récupérer les jobs par statut
const failedJobs = await queue.getJobs({
  status: 'failed',
  limit: 10
});

// Relancer un job échoué
await queue.retryJob(jobId);

// Nettoyer les jobs terminés
const deleted = await queue.clearJobs('completed');

Configuration avancée

const queue = createQueue({
  redisUrl: 'your-redis-url',
  redisToken: 'your-redis-token',
  queueName: 'my-queue'
}, {
  defaultMaxAttempts: 5,     // Tentatives par défaut
  retryDelay: 5000,          // Délai entre tentatives
  jobTTL: 7 * 24 * 60 * 60 * 1000  // TTL des jobs (7 jours)
});

Variables d'environnement

UPSTASH_REDIS_REST_URL=your_upstash_url
UPSTASH_REDIS_REST_TOKEN=your_upstash_token

Types disponibles

import type {
  QueueJob,
  QueueStats,
  JobStatus,
  AddJobOptions,
  QueueConfig
} from '@medeclipse/queue-as-a-service';

API Reference

QueueAsAService

  • addJob<T>(data: T, options?: AddJobOptions): Promise<QueueJob<T>>
  • getJob<T>(jobId: string): Promise<QueueJob<T> | null>
  • getJobs<T>(options?: GetJobsOptions): Promise<QueueJob<T>[]>
  • processNextJob<T>(): Promise<QueueJob<T> | null>
  • completeJob<T>(jobId: string, result?: T): Promise<void>
  • failJob(jobId: string, error: string): Promise<void>
  • retryJob(jobId: string): Promise<QueueJob | null>
  • deleteJob(jobId: string): Promise<boolean>
  • getStats(): Promise<QueueStats>
  • clearJobs(status?: JobStatus): Promise<number>
  • processDelayedJobs(): Promise<number>
  • processJobs<T>(processor, options?): Promise<void>

Exemples complets

Voir le fichier src/examples.ts pour des exemples détaillés d'utilisation.

License

MIT