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 🙏

© 2024 – Pkg Stats / Ryan Hefner

c9ms

v0.0.1

Published

Consumerism aims to provide lightweight abstractions over most used message brokers in order to enabled quick prototyping.

Downloads

59

Readme

c9m

Consumerism aims to provide lightweight abstractions over most used message brokers in order to enabled quick prototyping.

Abstracting base connection handling comes with the loss of control but the ability of swapping out messaging drivers with minimal to no changes.

Compromises have to be made in order to provide a common interface for message consumption/production; but the aim is to keep respective broker terminology intact.

Installing

npm install --save c9m

Usage

Given a naive WorkerBehaviour extension

import { WorkerBehaviour } from 'c9m';

class MyWorker extends WorkerBehaviour {
  public async onMessage(message: Buffer, handlers): Promise<void> {
    logger.info(`MyWorker Received message: ${message}`);

    // processing

    await handlers?.ack();
  }
}

Can then npm install --save mqtt
And then be initialised to work with MQTT via e.g.

const worker = new MyWorker({
  name: 'my-mqtt-consumer',
  protocol: 'mqtt',
  logger,
  host: 'localhost',
  port: 1883,
  username: 'user',
  password: 'pwd',
  topic: 'my-topic',
});

await worker.initialise();

Or npm install --save kafkajs
And then be initialised to work with Kafka via e.g.

const worker = new MyWorker({
  name: 'my-kafka-consumer',
  protocol: 'kafka',
  logger,
  host: 'localhost',
  port: 9093,
  username: 'user_kafka',
  password: 'secret',
  topic: 'my-topic',
});

await worker.initialise();

Or npm install --save amqplib
And then be initialised to work with AMQP via e.g.

const worker = new MyWorker({
  name: 'my-rabbit-consumer',
  protocol: 'amqp',
  logger,
  host: 'localhost',
  port: 5672,
  username: 'user',
  password: 'password',
  topic: 'my-queue',
});

await worker.initialise();

Note: the handling logic of the message never actually changed, only the initialisation config.

A producer can be initialised in the same way

import { Producer } from 'c9m';

MQTT e.g.

const producer = new Producer({
  name: 'my-mqtt-producer',
  protocol: 'mqtt',
  logger,
  host: 'localhost',
  port: 1883,
  username: 'user',
  password: 'pwd',
  topic: 'my-topic',
});

await producer.initialise();

await producer.publish('my-topic', Buffer.from('Hello, World 1010102!'));

Kafka e.g.

const producer = new Producer({
  protocol: 'kafka',
  name: 'my-kafka-producer',
  logger,
  host: 'localhost',
  port: 9093,
  username: 'user_kafka',
  password: 'secret',
  topic: 'my-topic',
});

await producer.initialise();

await producer.publish('my-topic', Buffer.from('Hello, World 1010102!'));

AMQP e.g.

const producer = new Producer({
  name: 'my-amqp-producer',
  protocol: 'amqp',
  logger,
  host: 'localhost',
  port: 5672,
  username: 'user',
  password: 'password',
  topic: 'my-queue',
});

await producer.initialise();

await producer.publish('my-queue', Buffer.from('Hello, World 1010102!'));

TODOs

A lot needs to be going on here :)

License

This library is licensed under the Apache 2.0 License