New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@strav/notification

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strav/notification

Strav multi-channel notifications — NotificationManager fan-out across channel drivers (mail / database / log / webhook / broadcast / discord / sse). Manager+drivers shape; new channels register via `manager.extend(name, factory)`.

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

@strav/notification

Multi-channel notifications for Strav 1.0. One fluent surface (notifications.send(notifiable, notification)) that fan-outs to ≥1 channel drivers — mail / database / log / webhook / broadcast / discord / sse today; SMS channel in a follow-up slice.

import { BaseNotification, type Notifiable, NotificationManager } from '@strav/notification'

class InvoicePaid extends BaseNotification {
  override via(): readonly string[] {
    return ['mail', 'database']
  }
  toMail(notifiable: Notifiable) {
    return { to: [notifiable.email], subject: 'Invoice paid', text: '...' }
  }
  toDatabase(_notifiable: Notifiable) {
    return { invoiceId: 'inv_42', amount: 4900 }
  }
}

const notifications = container.resolve(NotificationManager)
await notifications.send(alice, new InvoicePaid())

Canonical docs live in docs/notification/README.md.

What ships in v1

ChannelSubpathNotes
Mail@strav/notification/mailWraps @strav/mail's MailManager.send.
Database@strav/notification/databaseAppend-only notification ledger + NotificationRepository (unread() / markAsRead()). Tenanted variant under @strav/notification/tenanted.
Log@strav/notification/logRoutes through @strav/kernel's Logger. Useful for dev + tests.
Webhook@strav/notification/webhookPOSTs a signed JSON envelope (x-strav-signature: sha256=... over ${timestamp}.${body}) to a configured endpoint. Exports verifyWebhookSignature for receiver-side validation.
Broadcast@strav/notification/broadcastPublishes a BroadcastEvent via @strav/broadcast's Broadcaster. Pairs with router.sse(...) so live UI clients receive the same dispatch.
Discord@strav/notification/discordPOSTs notification.toDiscord(notifiable) to a Discord webhook URL. Returns a string (shorthand for { content }) or a DiscordMessage with embeds / components / per-message webhookUrl override. Per-recipient URLs via notifiable.discordWebhookUrl.
SSE@strav/notification/sseIn-process pub/sub. Reads notification.toSSE(notifiable) and pushes to every active subscriber for that notifiable. HTTP handlers consume subscriptions via driver.subscribe(id, { notifiableType? }) + sseResponse() from @strav/http.

Deferred: SMS channel driver. Apps register custom channels via manager.extend(name, factory).

FAQs

Package last updated on 01 Jun 2026

Related posts