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

@vp-k/notihub

v1.0.0

Published

Universal notification library for Telegram, Discord, and webhooks

Readme

한국어

notihub

Universal notification library for Telegram, Discord, and custom webhooks.

  • Zero dependencies — uses native fetch (Node >= 18)
  • Never throws — always returns a structured SendResult
  • Function-based API — simple, tree-shakeable
  • TypeScript-first with full type definitions
  • ESM + CJS dual build

Install

npm install notihub

Quick Start

import { createTelegram, createDiscord, createWebhook, sendAll } from "notihub";

const telegram = createTelegram({
  token: "YOUR_BOT_TOKEN",
  chatId: "YOUR_CHAT_ID",
});

const discord = createDiscord({
  webhookUrl: "https://discord.com/api/webhooks/...",
});

const webhook = createWebhook({
  url: "https://example.com/hook",
  body: (msg) => ({ text: msg }),
});

// Send to a single channel
const result = await telegram.send("Server deployed!");
// { ok: true, channel: "telegram" }
// { ok: false, channel: "telegram", error: "Unauthorized", status: 401 }

// Send to all channels at once
const results = await sendAll([telegram, discord, webhook], "Deploy complete");

API

createTelegram(config)

| Config | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | token | string | Yes | — | Telegram Bot API token | | chatId | string | No | — | Default chat ID | | parseMode | "HTML" \| "Markdown" | No | "HTML" | Message parse mode |

const tg = createTelegram({ token: "bot123:ABC", chatId: "456" });

await tg.send("Hello");
await tg.send("Hello", { chatId: "789" });          // override chatId
await tg.send("Hello", { parseMode: "Markdown" });  // override parseMode
await tg.send("Hello", { timeout: 5000 });           // custom timeout (default: 10s)

createDiscord(config)

| Config | Type | Required | Description | |--------|------|----------|-------------| | webhookUrl | string | Yes | Discord webhook URL |

const dc = createDiscord({ webhookUrl: "https://discord.com/api/webhooks/..." });

// Plain text
await dc.send("Hello");

// Rich embed
await dc.send("New order", {
  embeds: [{
    title: "Order #123",
    color: 0x00ff00,
    fields: [
      { name: "Customer", value: "John", inline: true },
      { name: "Total", value: "$99", inline: true },
    ],
  }],
});

// Custom bot name & avatar
await dc.send("Hello", { username: "MyBot", avatarUrl: "https://..." });

createWebhook(config)

| Config | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | url | string | Yes | — | Webhook endpoint URL | | method | HttpMethod | No | "POST" | HTTP method | | headers | Record<string, string> | No | {} | Default headers | | body | (msg: string) => unknown | No | { message } | Custom body builder |

const wh = createWebhook({
  url: "https://example.com/hook",
  headers: { Authorization: "Bearer token" },
  body: (msg) => ({ text: msg, source: "notihub" }),
});

await wh.send("Alert!");
await wh.send("Alert!", { headers: { "X-Priority": "high" } }); // merge headers

sendAll(channels, message)

Sends a message to multiple channels concurrently using Promise.allSettled. One channel's failure does not affect others.

const results = await sendAll([telegram, discord, webhook], "Deploy complete");
// [
//   { ok: true, channel: "telegram" },
//   { ok: false, channel: "discord", error: "...", status: 404 },
//   { ok: true, channel: "webhook" },
// ]

Utilities

import { escapeHtml, truncate } from "notihub";

escapeHtml("<b>bold & safe</b>");  // "&lt;b&gt;bold &amp; safe&lt;/b&gt;"
truncate("Long message...", 10);    // "Long me..."

SendResult

All send() calls return a SendResult:

type SendResult =
  | { ok: true; channel: string }
  | { ok: false; channel: string; error: string; status?: number };
  • ok: true — message sent successfully
  • ok: false — failed, with human-readable error and optional HTTP status
  • Never rejects — safe to use fire-and-forget:
telegram.send("alert").then(r => !r.ok && console.error(r.error));

License

MIT