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

@helpful-insight/notifications

v1.0.2

Published

Enterprise Multi-Channel Notification Service (In-App, Email, Push, Webhooks) with user channel preferences and SSE streaming

Readme

@helpful-insight/notifications

npm version License: MIT TypeScript

Enterprise multi-channel notification engine for Node.js, Express, and Prisma. Dispatches notifications seamlessly across In-App (Database + Live Server-Sent Events SSE stream), Email, and HMAC-signed Webhooks, with full support for user channel preferences and category-level muting.


🌟 Key Features

  • 📡 Multi-Channel Dispatching:
    • in_app: Stores notifications in DB and pushes instantly to active browser sessions via SSE.
    • email: Routes through transactional email providers (e.g. @helpful-insight/mailer).
    • webhook: POSTs JSON payloads with cryptographic HMAC-SHA256 signature validation headers.
  • ⚡ Live Real-time Server-Sent Events (SSE):
    • Zero-dependency real-time push to frontend clients without needing WebSocket servers.
    • Auto-reconnect handling and client connection lifecycle management.
  • 🎛️ Granular User Preferences:
    • Users can enable/disable channels per notification category (e.g. marketing, security, transactional).
    • If a user mutes marketing emails, the dispatcher automatically skips the email channel while still delivering essential in-app alerts.
  • 🌐 Turnkey Express Router:
    • Full REST + SSE API: GET /, PATCH /:id/read, POST /read-all, GET /stream, GET /preferences, PUT /preferences.
  • 🗄️ Prisma Database Storage:
    • Built-in Prisma schema models for notifications and user preferences.

📦 Installation

# npm
npm install @helpful-insight/notifications

# pnpm
pnpm add @helpful-insight/notifications

# yarn
yarn add @helpful-insight/notifications

🚀 Quick Start

import { NotificationService } from '@helpful-insight/notifications';

const notifications = new NotificationService({
  defaultChannels: ['in_app']
});

// Dispatch notification
const { id, results } = await notifications.send({
  userId: 'user_123',
  category: 'transactional',
  title: 'Order Shipped',
  message: 'Your parcel #84920 has shipped!',
  data: { orderId: '84920', carrier: 'FedEx' }
});

console.log(id); // Notification UUID
console.log(results); // [{ channel: 'in_app', success: true }]

⚡ Real-Time In-App & Express Integration

Mount the pre-built notification router in Express:

import express from 'express';
import { NotificationService, createNotificationRouter } from '@helpful-insight/notifications';

const app = express();
app.use(express.json());

// Mock auth middleware to attach user
app.use((req, res, next) => {
  req.user = { id: 'user_123' };
  next();
});

const notifications = new NotificationService();
app.use('/api/notifications', createNotificationRouter(notifications));

Frontend SSE Client Connection (React / Vue / Vanilla JS):

// Connect to real-time stream in browser
const eventSource = new EventSource('/api/notifications/stream');

eventSource.onmessage = (event) => {
  const notification = JSON.parse(event.data);
  console.log('New notification received:', notification.title, notification.message);
  // Update UI badge or trigger toast popup
};

🎛️ User Channel Preferences

Allow users to customize which notifications they receive:

// Mute marketing emails for a user
await notifications.getPreferencesStore().setPreference(
  'user_123',
  'marketing',
  'email',
  false // muted
);

// This notification will skip email because user muted it
await notifications.send({
  userId: 'user_123',
  category: 'marketing',
  title: 'Weekend Sale!',
  message: '20% off on all items.',
  recipientEmail: '[email protected]'
});

🗄️ Prisma Database Schema

model Notification {
  id        String   @id @default(uuid())
  userId    String
  title     String
  message   String
  category  String   @default("general")
  data      String?  // JSON string
  isRead    Boolean  @default(false)
  createdAt DateTime @default(now())

  @@index([userId, isRead])
}

model NotificationPreference {
  id        String   @id @default(uuid())
  userId    String
  category  String
  channel   String
  enabled   Boolean  @default(true)
  updatedAt DateTime @updatedAt

  @@unique([userId, category, channel])
}

📄 License

MIT © Helpful Insight Private Limited