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

cda-utils

v0.0.26

Published

## Installation

Readme

CDA UTILS

Installation

$ npm install

Usage of Activity Stream

const { KafkaService } = require("cda-utils");

const topics = [YOUR_KAFKA_PRODUCER];
const getProducerConfig = () => {
    let conf = {
      clientId: `your-client-id`,
      brokers: ['hostnames'],
      producerProperties: {
        transactionalId: "unique-sample-transaction-id",
        maxInFlightRequests: 1,
        idempotent: true,
      },//this config is preffred by kafkajs https://kafka.js.org/docs/transactions
    }
    if (
      process.env.KAFKA_SASL_USERNAME ||
      global.Config.broker.kafka.sasl_username
    ) {
      conf = {
        ...conf,
        "sasl.username":
          process.env.KAFKA_SASL_USERNAME ||
          global.Config.broker.kafka.sasl_username,
        "sasl.password":
          process.env.KAFKA_SASL_PASSWORD ||
          global.Config.broker.kafka.sasl_password,
        "security.protocol": "SASL_PLAINTEXT",
        "sasl.mechanisms": "PLAIN",
      };
    }
    return conf;
};

const getConsumerConfig = () => {
    let conf = {
      clientId: `your-client-id`,
      brokers: ['hostnames'],
      consumerProperties: {
        groupId: `your-group-id`,
        readUncommited: false, //only for producer using transactions
      },
    }
    if (
      process.env.KAFKA_SASL_USERNAME ||
      global.Config.broker.kafka.sasl_username
    ) {
      conf = {
        ...conf,
        "sasl.username":
          process.env.KAFKA_SASL_USERNAME ||
          global.Config.broker.kafka.sasl_username,
        "sasl.password":
          process.env.KAFKA_SASL_PASSWORD ||
          global.Config.broker.kafka.sasl_password,
        "security.protocol": "SASL_PLAINTEXT",
        "sasl.mechanisms": "PLAIN",
      };
    }
    return conf;
};

const Kafka = new KafkaService(getProducerConfig());
const kafkaEventDelegator = async (messageReceived) => {
  try {
    const message = messageReceived.content;
    if (message.eventName === "test") {
      console.log("test kafka event");
      return false;   //this will mark message as processed
    }
  } catch (e) {
      return false;   //this will push the message for DLQ
      console.log(error.response.data);
  }

  // Do something with the message
};
const kafkaConsumerConfig = {
  prefetch: 10,
  ...getConsumerConfig(),
};
let index= 0;
async function testPushToQueue() {
  await Kafka.pushToQueue(
    "dev-test",
    [
      {
        eventName: "test",
        data: {
          val: `hello world ${index} `,
          index: 2,
        },
      },
    ],
    {
      "replication-factor": 1,
    }
  );
  await Kafka.commitTransaction(); //commit or abort this so transaction can reach the end state
  index++;
}
async function init() {
  Kafka.listenQueue(topics, kafkaEventDelegator, kafkaConsumerConfig);
  setInterval(testPushToQueue, 10000);
}
try {
  init();
} catch (error) {
  console.log(error);
}

Usage of Kafka Broker

const cda_utils = require('cda-utils');
const Kafka_Broker = cda_utils.Broker.Kafka;

Mandatory Config for cda_utils

global.Config = {};
global.Config.env = '';
global.Config.cda_utils = {};
global.Config.cda_utils.queueName = 'skuad-events';
global.Config.cda_utils.broker = {};
global.Config.cda_utils.broker.maxQueueSize = '100'
global.Config.cda_utils.broker.kafka = {
    brokers: 'localhost:9092',
    commitTimeInterval: '1',
    maxParallelHandles: '10',
    messageProcessingTimeoutMS: '1'
};
};