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

notifx

v1.0.0

Published

Pluggable notification dispatcher to send notifications to various channels.

Readme

notifx

NotifX is a lightweight, pluggable notification dispatching system for Node.js. Registers notification channels (like Email, Telegram, ...) using built-in dispatcher functions or provide your own to handle a actual message delivery.

Features

  • Register custom notification channels with dispatcher functions
  • Built-in plugins: Email (via Nodemailer), Telegram,... more to come
  • Send notifications by name with flexible arguments
  • Supports both synchronous and asynchronous dispatchers
  • Type-safe in TypeScript

Installation

npm install notifx

Usage

import notifx, { emailPlugin } from "notifx";

const channel = "email";
const template =
    '<!DOCTYPE html>\
<html>\
    <head>\
        <meta charset="UTF-8" />\
        <title>My company</title>\
    </head>\
    <body>\
        {{{username}}}\
    </body>\
</html>\
';

// Register a channel using the built-in email plugin
notifx.registerChannel(
    channel, // channel name
    emailPlugin.sendEmail({
        // returns actual function that send emails
        host: "smtp.example.com",
        port: 587,
        auth: { user: "[email protected]", pass: "secret" },
    })
);

// Register a notification to send a welcome email
notifx.registerNotification(
    "welcomeEmail", // notification name
    channel, // channel name
    [
        // The array will be spread as arguments of Email dispatcher to send email
        template, // HTML body (can be a file path)
        "[email protected]", // from
        "[email protected]", // to
        "Welcome {{username}}!", // subject
        {
            // replacements
            body: { username: "jonhdoe" },
            title: { username: "jonhdoe" },
        },
    ]
);

// Send the registered notification
await notifx.send("welcomeEmail");

Plugin System

Email Plugin (via Nodemailer)

How to use

import { emailPlugin } from "notifx";

const send = emailPlugin.sendEmail(mailerOptions);
await send(body, from, to, title, replacements, attachments?);

Telegram Plugin (via Nodemailer)

How to use

import { telegramPlugin } from "notifx";

const send = telegramPlugin.sendTelegramMessage(botToken);
await send(chatId, messageTemplate, { message: { username: "jonhdoe" } });

Using Custom Dispatchers

NotifX is designed to be flexible and extensible. Beyond the built-in plugins, you can register your own custom dispatcher functions to handle message delivery any way you want.

A dispatcher function is simply a function that accepts a fixed set of arguments (matching the array you provided when registerering a notification) and performs the actual delivery logic — it can be synchronous or asynchronous. See below how to register a custom dispatcher.

This code will log: Sending message to [email protected]: Hello there!.

// Define your custom dispatcher function.
const myDispatcher = async (recipient: string, message: string) => {
    // Implement your custom delivery logic here
    console.log(`Sending message to ${recipient}: ${message}`);
    // For example, call an external API, send SMS, log to a database, etc.
    return true;
};

const recipient = "[email protected]";
const message = "Hello there!";

// Register your custom channel
notifx.registerChannel("customChannel", myDispatcher);

// Register a notification using your custom channel
notifx.registerNotification("myNotification", "customChannel", [
    // The array will be spread as  arguments of myDispatch when calling it
    recipient,
    message,
]);

// Send the notification
await notifx.send("myNotification");

Important

  • The dispatcher function's parameters must match the array you provide when registering the notification.
  • NotifX will invoke the dispatcher with the registered arguments unless you override them during send() passing additional arguments after the notification name.

API

notifx.registerChannel(name, dispatcher)

Registers a dispatcher function for a given channel name.

notifx.registerNotification(name, channel, dispatcherArgs)

Binds a notification name to a channel with specific arguments.

notifx.send(notificationName, ...overrideArgs?)

Dispatches a notification through its associated channel, optionally overriding arguments.

To Do

  • [ ] Retry logic
  • [ ] Monitoring
  • [ ] More plugins

Contributions

Contributions are welcome. See CONTRIBUTING.md.