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

@zintrust/queue-cloudflare

v2.9.0

Published

Cloudflare Queues driver for ZinTrust.

Readme

@zintrust/queue-cloudflare

Cloudflare Queues driver for ZinTrust.

import '@zintrust/queue-cloudflare/register';
import { Queue } from '@zintrust/core/queue';

await Queue.enqueue('EMAIL_QUEUE', { to: '[email protected]' }, 'cloudflare');

BullMQ-like stateful jobs are available through the package driver:

import { CloudflareQueues } from '@zintrust/queue-cloudflare';

const queue = CloudflareQueues.create({
  driver: 'cloudflare',
  bindingName: 'EMAIL_QUEUE',
  state: {
    d1BindingName: 'QUEUE_DB',
    kvBindingName: 'QUEUE_KV',
    coordinatorBindingName: 'QUEUE_COORDINATOR',
  },
});

const job = await queue.add(
  'email-queue',
  'send-email',
  { to: '[email protected]' },
  {
    attempts: 5,
    backoff: { type: 'exponential', delay: 1000 },
    priority: 2,
    delay: 30000,
  }
);

await queue.getJob('email-queue', job.id);
await queue.getJobCounts('email-queue', 'waiting', 'active', 'completed', 'failed');

Inside a Cloudflare Worker, bind the queue in wrangler.jsonc:

{
  "queues": {
    "producers": [{ "queue": "email-queue", "binding": "EMAIL_QUEUE" }],
    "consumers": [
      {
        "queue": "email-queue",
        "max_batch_size": 10,
        "max_retries": 3,
        "dead_letter_queue": "email-dlq",
      },
    ],
  },
}

Add the state bindings when using BullMQ-like metadata:

{
  "d1_databases": [
    {
      "binding": "QUEUE_DB",
      "database_name": "zintrust-queue",
      "database_id": "<database-id>",
    },
  ],
  "kv_namespaces": [
    {
      "binding": "QUEUE_KV",
      "id": "<namespace-id>",
    },
  ],
  "durable_objects": {
    "bindings": [
      {
        "name": "QUEUE_COORDINATOR",
        "class_name": "CloudflareQueueCoordinator",
      },
    ],
  },
  "migrations": [
    {
      "tag": "queue-cloudflare-v1",
      "new_sqlite_classes": ["CloudflareQueueCoordinator"],
    },
  ],
  "triggers": {
    "crons": ["* * * * *"],
  },
}

Run the D1 state migration:

zin migrate:queue-cloudflare --database zintrust-queue --local
zin migrate:queue-cloudflare --database zintrust-queue --remote

The same migration is available programmatically:

import { CloudflareQueueMigrator } from '@zintrust/queue-cloudflare';

await CloudflareQueueMigrator.up({ d1: env.QUEUE_DB });

Use the Worker queue consumer helper:

const consumer = queue.createConsumer(async (data, context) => {
  await context.updateProgress({ step: 'sending' });
  return await sendEmail(data);
}, 'email-queue');

export default {
  async queue(batch) {
    await consumer.processBatch(batch);
  },
  async scheduled() {
    await queue.runScheduler('email-queue');
  },
};

For HTTP pull consumers or non-Worker producers, configure Cloudflare API access:

import { CloudflareQueues } from '@zintrust/queue-cloudflare';

const queue = CloudflareQueues.create({
  driver: 'cloudflare',
  accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
  queueId: process.env.CLOUDFLARE_QUEUE_ID,
  apiToken: process.env.CLOUDFLARE_API_TOKEN,
  batchSize: 1,
  visibilityTimeoutMs: 30000,
});

const jobId = await queue.enqueue('email-queue', { to: '[email protected]' });
const message = await queue.dequeue('email-queue');
if (message) await queue.ack('email-queue', message.id);

Environment fallbacks:

  • CLOUDFLARE_QUEUE_BINDING or QUEUE_BINDING
  • CLOUDFLARE_ACCOUNT_ID or CF_ACCOUNT_ID
  • CLOUDFLARE_QUEUE_ID or CF_QUEUE_ID
  • CLOUDFLARE_API_TOKEN or CF_API_TOKEN
  • CLOUDFLARE_API_BASE_URL

The driver registers as both cloudflare and cloudflare-queues.