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

nestjs-local-events

v0.0.1

Published

Dev-only helper for dispatching events directly to local consumers in NestJS (bypass Kafka/Rabbit during local dev).

Downloads

6

Readme

nestjs-local-events

Lightweight dev-only helper for NestJS. During local development, it delivers events directly to in-process consumer methods, bypassing external brokers. In production it is a no-op.

Why

Debugging is easier when producers and consumers run in the same process locally. Mark the producer method with a decorator and mark the consumer with a decorator; when NODE_ENV !== 'production', emitted events are routed instantly to the matching consumers.

Installation

npm i -D nestjs-local-events
import { Module } from '@nestjs/common';
import { LocalEventsModule } from 'nestjs-local-events';

@Module({
  imports: [
    ...(process.env.NODE_ENV !== 'production' ? [LocalEventsModule.forRoot()] : []),
  ],
})
export class AppModule {}

End-to-end Example

This is a complete, minimal flow for a single case: an Order domain.

// events.ts
export enum OrderEvents {
  OrderPlaced = 'order.placed',
  PaymentCaptured = 'payment.captured',
}
// order.consumer.ts
import { Injectable } from '@nestjs/common';
import { LocalConsumer } from 'nestjs-local-events';
import { OrderEvents } from './events';

@Injectable()
export class OrderConsumer {
  public seen: Array<{ type: OrderEvents; payload: unknown }> = [];

  @LocalConsumer(OrderEvents.OrderPlaced)
  async onOrderPlaced(payload: { orderId: string; userId: string }) {
    this.seen.push({ type: OrderEvents.OrderPlaced, payload });
  }
}
// order.service.ts
import { Injectable } from '@nestjs/common';
import { Local as RouteLocal, LocalEventBus, LocalEventMessage } from 'nestjs-local-events';
import { OrderEvents } from './events';

@Injectable()
export class OrderService {
  constructor(public readonly localEventBus: LocalEventBus) {}

  @RouteLocal()
  async place(dto: { userId: string }): Promise<LocalEventMessage<{ orderId: string; userId: string }>> {
    const orderId = 'o-1';
    return { type: OrderEvents.OrderPlaced, payload: { orderId, userId: dto.userId } };
  }

  @RouteLocal({
    extractor: (_args, result: { id: string; amount: number }) => ({
      type: OrderEvents.PaymentCaptured,
      payload: { orderId: result.id, amount: result.amount },
    }),
  })
  async capture(orderId: string) {
    return { id: orderId, amount: 5000 };
  }
}

Behavior

  • When NODE_ENV !== 'production', methods decorated with Local (aliased as RouteLocal above) extract an event from the method result and dispatch it to all @LocalConsumer(event) handlers in the same process.
  • When NODE_ENV === 'production', the decorator does nothing and simply returns the original method result.

Requirements

  • The producer class must inject LocalEventBus as a public field: constructor(public readonly localEventBus: LocalEventBus) {}.
  • You may return a LocalEventMessage from the method, or provide an extractor to convert arbitrary results into a LocalEventMessage.

API

type EventEnum = string | number

interface LocalEventMessage<Payload = unknown> {
  type: EventEnum
  payload: Payload
}

type ExtractorFn = (args: unknown[], result: unknown) => LocalEventMessage | LocalEventMessage[] | null | undefined

interface LocalOptions {
  extractor?: ExtractorFn
  enabled?: boolean
}

declare function Local(event?: LocalOptions): MethodDecorator
declare function LocalConsumer(event: EventEnum): MethodDecorator

Publishing

  • CI runs build and tests on every push and PR.
  • Creating a tag vX.Y.Z triggers the release workflow.
  • The workflow enforces the package.json version to match the tag and publishes to npm using NPM_TOKEN.