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

@glidemq/nestjs

v0.2.2

Published

NestJS module for glide-mq - decorators, dependency injection, and lifecycle management for queues and workers

Readme

@glidemq/nestjs

npm license

NestJS module for glide-mq - type-safe decorators and DI for high-performance queues with AI orchestration.

Why

  • Decorator-based processors - @Processor and @BroadcastProcessor auto-wire workers on startup
  • Full DI integration - @InjectQueue, @InjectFlowProducer, @InjectBroadcast, @InjectProducer work with NestJS's container
  • Zero-boilerplate shutdown - all workers, queues, and connections close automatically via OnApplicationShutdown

Install

npm install @glidemq/nestjs glide-mq @nestjs/common @nestjs/core

Requires glide-mq >= 0.14.0 and NestJS 10+.

Quick start

// app.module.ts
import { Module } from "@nestjs/common";
import { GlideMQModule } from "@glidemq/nestjs";

@Module({
  imports: [
    GlideMQModule.forRoot({
      connection: { addresses: [{ host: "localhost", port: 6379 }] },
    }),
    GlideMQModule.registerQueue({ name: "emails" }),
  ],
  providers: [EmailProcessor, EmailService],
})
export class AppModule {}

// email.processor.ts
import { Processor, WorkerHost, OnWorkerEvent } from "@glidemq/nestjs";
import type { Job } from "glide-mq";

@Processor("emails")
export class EmailProcessor extends WorkerHost {
  async process(job: Job) {
    await sendEmail(job.data.to, job.data.subject);
    return { sent: true };
  }

  @OnWorkerEvent("failed")
  onFailed(job: Job, err: Error) {
    console.error(`Job ${job.id} failed:`, err.message);
  }
}

// email.service.ts
import { Injectable } from "@nestjs/common";
import { InjectQueue } from "@glidemq/nestjs";
import type { Queue } from "glide-mq";

@Injectable()
export class EmailService {
  constructor(@InjectQueue("emails") private readonly queue: Queue) {}

  async send(to: string, subject: string) {
    await this.queue.add("send", { to, subject });
  }
}

AI-native features

glide-mq 0.14+ provides AI orchestration primitives - token/cost tracking, real-time streaming, human-in-the-loop suspend/signal, model failover chains, budget caps, dual-axis rate limiting, vector search, and rolling usage summaries. All are accessible through the injected Queue, Worker, FlowProducer, Broadcast, and QueueEvents instances in your NestJS services.

If you need to create and inspect flows over HTTP from cross-language or non-Nest clients, use the core glide-mq proxy or one of the HTTP wrapper integrations:

  • @glidemq/hono
  • @glidemq/fastify
  • @glidemq/hapi

These expose:

  • POST /flows
  • GET /flows/:id
  • GET /flows/:id/tree
  • DELETE /flows/:id

@glidemq/nestjs is a DI/module integration and does not provide an HTTP API layer.

Usage tracking and streaming

// llm.processor.ts
import { Processor, WorkerHost } from "@glidemq/nestjs";
import type { Job } from "glide-mq";

@Processor("llm-tasks")
export class LlmProcessor extends WorkerHost {
  async process(job: Job) {
    const response = await callLlm(job.data.prompt);

    // Stream reasoning and content chunks back in real time
    for (const chunk of response.reasoningChunks) {
      await job.streamChunk("reasoning", chunk);
    }
    for (const chunk of response.contentChunks) {
      await job.streamChunk("content", chunk);
    }
    await job.streamChunk("done");

    // Report token usage and cost
    await job.reportUsage({
      model: "claude-sonnet-4-20250514",
      provider: "anthropic",
      tokens: {
        input: response.inputTokens,
        output: response.outputTokens,
        reasoning: response.reasoningTokens,
      },
      costs: { total: response.cost },
      costUnit: "usd",
    });

    return { result: response.text };
  }
}

Flow-level budgets

// orchestration.service.ts
import { Injectable } from "@nestjs/common";
import { InjectFlowProducer } from "@glidemq/nestjs";
import type { FlowProducer } from "glide-mq";

@Injectable()
export class OrchestrationService {
  constructor(
    @InjectFlowProducer("llm-flow") private readonly flow: FlowProducer,
  ) {}

  async runChain(prompt: string) {
    await this.flow.add(
      {
        name: "summarize",
        queueName: "llm-tasks",
        data: { prompt },
        children: [
          { name: "research", queueName: "llm-tasks", data: { prompt } },
          { name: "draft", queueName: "llm-tasks", data: { prompt } },
        ],
      },
      {
        budget: {
          maxTotalTokens: 10000,
          tokenWeights: { reasoning: 4, cachedInput: 0.25 },
          maxTotalCost: 0.5,
          costUnit: "usd",
          onExceeded: "fail",
        },
      },
    );
  }
}

The budget is enforced across all jobs in the flow. When the weighted token total or cost cap is hit, remaining jobs fail (or pause, depending on onExceeded). See the glide-mq docs for the full API.

Queue-wide usage summaries

import { Injectable } from "@nestjs/common";
import { InjectQueue } from "@glidemq/nestjs";
import type { Queue } from "glide-mq";

@Injectable()
export class UsageService {
  constructor(@InjectQueue("llm-tasks") private readonly queue: Queue) {}

  async summary() {
    return this.queue.getUsageSummary({ windowMs: 60_000 });
  }
}

Use the instance method for queue-local summaries, or Queue.getUsageSummary(...) when you want to aggregate across multiple queues.

Configuration

| Method | Description | |--------|-------------| | GlideMQModule.forRoot(opts) | Global module with connection config | | GlideMQModule.forRootAsync(opts) | Async config via useFactory, useClass, or useExisting | | GlideMQModule.registerQueue(...opts) | Register queues for injection | | GlideMQModule.registerFlowProducer(...opts) | Register FlowProducers for DAG workflows | | GlideMQModule.registerBroadcast(...opts) | Register Broadcast instances for pub/sub | | GlideMQModule.registerProducer(...opts) | Register lightweight Producers (serverless) |

Decorators: @Processor, @BroadcastProcessor, @InjectQueue, @InjectFlowProducer, @InjectBroadcast, @InjectProducer, @OnWorkerEvent, @QueueEventsListener, @OnQueueEvent

Testing

Pass testing: true to use in-memory TestQueue/TestWorker - no Valkey required:

const moduleRef = await Test.createTestingModule({
  imports: [
    GlideMQModule.forRoot({ testing: true }),
    GlideMQModule.registerQueue({ name: "emails" }),
  ],
  providers: [EmailProcessor, EmailService],
}).compile();
const service = moduleRef.get(EmailService);
await service.send("[email protected]", "Hello");

Limitations

  • Requires NestJS 10+ and Node.js 20+.
  • @BroadcastProcessor and @QueueEventsListener are skipped in testing mode.
  • registerBroadcast and registerProducer always require a live connection (no testing mode).

Links

License

Apache-2.0