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

@plyaz/notifications

v1.3.0

Published

πŸ”” Unified notification system delivering real-time alerts across email, SMS, push, and in-app channels. Built for scalability with Redis queues and multi-tenant support

Downloads

77

Readme

@plyaz/notifications

Unified, multi-channel notification system for email, SMS, and push notifications with multi-provider support, template engine, webhook tracking, and production-ready compliance features.

Installation

pnpm add @plyaz/notifications

Requirements:

  • Node.js >= 22.4.0
  • pnpm >= 8.0.0

Quick Start

Basic Email Notification

import { NotificationService, SendGridAdapter } from '@plyaz/notifications';

const service = new NotificationService({
  providers: {
    email: [new SendGridAdapter({
      apiKey: process.env.SENDGRID_API_KEY!,
      fromEmail: '[email protected]',
      fromName: 'My App'
    })],
    sms: [],
    push: []
  }
});

// Send email with template
const result = await service.sendEmail({
  recipientId: 'user-123',
  to: '[email protected]',
  templateId: 'welcome',
  templateData: { userName: 'John' },
  locale: 'en'
});

if (result.success) {
  console.log('Email sent:', result.data.providerMessageId);
}

Multi-Provider with Fallback

import {
  NotificationService,
  SendGridAdapter,
  InfobipEmailAdapter,
  createProductionLogger
} from '@plyaz/notifications';

const logger = createProductionLogger({ service: 'notifications' });

const service = new NotificationService({
  providers: {
    email: [
      new SendGridAdapter({ apiKey: '...', priority: 1 }, logger),  // Primary
      new InfobipEmailAdapter({ apiKey: '...', priority: 2 }, logger)  // Fallback
    ],
    sms: [],
    push: []
  },
  logger
});

Template System

Create template at templates/en/email/welcome.md:

---
subject: Welcome {{userName}}!
channel: email
category: transactional
layout: branded
---

# Welcome to our platform, {{userName}}!

Thanks for signing up. Get started by clicking below:

[Get Started]({{dashboardUrl}})

Webhooks (SendGrid)

import {
  SendGridAdapter,
  SendGridWebhookAdapter
} from '@plyaz/notifications';

const service = new NotificationService({
  providers: {
    email: [new SendGridAdapter({
      apiKey: process.env.SENDGRID_API_KEY!,
      fromEmail: '[email protected]',
      webhooks: [
        new SendGridWebhookAdapter({
          verificationKey: process.env.SENDGRID_WEBHOOK_KEY!,
          onDelivered: (event) => {
            console.log('Email delivered:', event.messageId);
          },
          onBounced: (event) => {
            console.log('Email bounced:', event.reason);
          }
        })
      ]
    })],
    sms: [],
    push: []
  }
});

Features

Multi-Channel Support

  • βœ… Email - SendGrid, Infobip adapters (100% complete)
  • ⏳ SMS - Mock adapter complete, providers pending
  • ⏳ Push - Mock adapter complete, providers pending

Template System

  • Markdown + Handlebars templates
  • Multi-language support (i18n)
  • 4 layout variants (branded, minimal, transactional, none)
  • Automatic CSS inlining for emails
  • YAML frontmatter configuration

Provider Management

  • Multi-provider setup with automatic failover
  • Priority-based routing (1 = highest)
  • Circuit breaker pattern
  • Health monitoring
  • Retry logic with exponential backoff

Compliance & Security

  • RFC 8058 one-click unsubscribe
  • User preference management
  • Token generation (AES-256-GCM, JWT, HMAC-SHA256)
  • PII redaction and hashing
  • Webhook signature verification

Webhooks

  • SendGrid webhook support (ECDSA/HMAC verification)
  • Infobip delivery & tracking webhooks
  • Event normalization
  • Idempotency handling
  • Multiple webhook handlers

Advanced Features

  • Bulk sending optimization (adapter-level bulk APIs)
  • Attachment support (buffer, URL, file path)
  • SMS character validation (GSM-7, UCS-2)
  • URL shortening (3 adapter types)
  • Inline CSS for email compatibility
  • Event system (lifecycle, debug, error events)

Channel Support Matrix

| Feature | Email | SMS | Push | |---------|-------|-----|------| | Providers | SendGrid, Infobip, Mock | Mock | Mock | | Templates | βœ… Full | βœ… Full | βœ… Full | | Attachments | βœ… Yes | ❌ No | ❌ No | | Webhooks | βœ… Yes | ⏳ Pending | ⏳ Pending | | Bulk Sending | βœ… Yes | ⏳ Pending | ⏳ Pending | | Unsubscribe | βœ… Yes | ⏳ Pending | ⏳ Pending |

Development Commands

# Development
pnpm dev              # Watch mode development
pnpm build            # Build for production
pnpm clean            # Clean dist directory

# Testing
pnpm test             # Run tests once
pnpm test:watch       # Run tests in watch mode
pnpm test:coverage    # Run tests with coverage
pnpm test:ui          # Open Vitest UI

# Code Quality
pnpm lint             # Run ESLint
pnpm lint:fix         # Auto-fix linting issues
pnpm format           # Format code with Prettier
pnpm type:check       # TypeScript type checking

# Examples
pnpm example:order-email          # Full feature showcase
pnpm example:attachments          # Attachments guide
pnpm example:unsubscribe          # Unsubscribe system
pnpm example:preferences          # User preferences
pnpm example:webhook-complete     # Production webhooks
pnpm test:sms-validation          # SMS validation
pnpm test:url-shortening          # URL shortening

Package Dependencies

Per Plyaz monorepo architecture:

Uses

  • @plyaz/types/notifications - Type definitions
  • @plyaz/logger - Structured logging with PII redaction
  • @plyaz/api - Global API configuration
  • @plyaz/errors - Error handling with correlation IDs

External Dependencies

  • @sendgrid/mail - SendGrid API client
  • handlebars - Template engine
  • marked - Markdown to HTML
  • juice - CSS inlining for emails
  • gray-matter - YAML frontmatter parsing
  • zod - Schema validation

Documentation

Architecture

NotificationService
β”œβ”€β”€ ProviderRegistry (adapter selection & routing)
β”œβ”€β”€ TemplateEngine (Markdown + Handlebars)
β”œβ”€β”€ EventManager (lifecycle events)
β”œβ”€β”€ QueueProcessor (async processing)
└── WebhookManager (delivery tracking)
    β”œβ”€β”€ Email Adapters (SendGrid, Infobip, Mock)
    β”œβ”€β”€ SMS Adapters (Mock)
    └── Push Adapters (Mock)

Error Handling

Uses Result type pattern - no exceptions!

const result = await service.sendEmail({ /* ... */ });

if (result.success) {
  console.log('Sent:', result.data.providerMessageId);
  console.log('Retry attempts:', result.data.retryAttempts);
} else {
  console.error('Failed:', result.error.message);
  console.error('Error code:', result.error.code);
}

Event System

const service = new NotificationService({
  providers: { /* ... */ },

  // Lifecycle events
  events: {
    onSent: (event) => console.log('Sent:', event.notificationId),
    onFailed: (event) => console.error('Failed:', event.error),
    onDelivered: (event) => console.log('Delivered:', event.notificationId)
  },

  // Debug events
  debugEvents: {
    onFallbackTriggered: (event) => {
      console.warn('Fallback:', event.metadata?.nextProvider);
    }
  },

  // Error handlers
  errorHandlers: {
    onProviderError: async (error) => {
      await errorTracking.report(error);
    }
  }
});

Contributing

When adding new features:

  1. Add types to @plyaz/types/notifications
  2. Implement feature with full TypeScript support
  3. Add comprehensive tests (90% coverage minimum)
  4. Update documentation (USAGE.md, API-REFERENCES.md)
  5. Add example in examples/ directory
  6. Update IMPLEMENTATION_STATUS.md

License

ISC Β© Plyaz