Skip to content

apps/api/src/lib/notifier.ts ​

Auto-generated by scripts/generate-file-docs.ts. Do not edit — overwritten on every run.

Purpose ​

Notifier — multi-channel notification dispatcher. Fans a single payload out to a set of users across EMAIL / SMS / PUSH channels per each user's individual preferences (notifyByEmail, notifyBySms, notifyByPush on the User row). IN_APP delivery is handled by the persistence path in caller services (e.g. AnnouncementReceipt rows) — this dispatcher only handles outbound transport channels. This is a service-layer collaborator: it is NEVER called from route handlers directly. Feature services (events, announcements, auth) inject or import the singleton from notifier.factory.ts and call notify(). Design rules (ADR 0013): - Provider adapters MUST NOT throw on delivery failure. Even so, this dispatcher wraps each channel in a try/catch so a buggy adapter cannot block sibling channels for sibling users. - All per-user channel sends run in parallel (Promise.allSettled) — a slow SMS send does not delay an email send. - Push is batched: one provider call carries every push token across every recipient who has notifyByPush enabled. - SMS bodies are truncated to 160 characters to avoid silent splits across multiple billable segments (carrier-dependent). /

Exports ​

  • export interface NotifyPayload
  • export class Notifier

Imports ​

  • ../adapters/email/EmailProvider
  • ../adapters/notifications/NotificationsProvider
  • ../adapters/sms/SmsProvider
  • ./logger
  • @hch/shared-types
  • @prisma/client
  • web-push

Imported by ​

Heritage Community Hub — Internal. Access restricted via Cloudflare Access + Entra ID.