Skip to main content
The Broadcast Notification (@spurtcommerce/broadcast-notification) adds scheduled and real-time broadcast notifications to SpurtCommerce Community and Enterprise editions. It allows vendors and administrators to create and manage broadcast notifications, schedule publication, and deliver notification updates to buyers. Buyers can retrieve their notifications and manage their read, clicked, and deleted states. The package integrates with the SpurtCommerce application through its TypeORM, Express, and plugin loaders. It uses BullMQ for background processing and Socket.IO for real-time delivery.

Key Features

  • Broadcast management: Create, list, view, update, and delete broadcast notifications for vendors and administrators.
  • Scheduled publishing: Queue notifications for publication at a configured future date and time, with delayed job support.
  • Background processing: Use a BullMQ queue and worker to process scheduled broadcasts outside the request-response cycle.
  • Multi-tenant processing: Process notification jobs in a multi-tenant application while retaining tenant context.
  • Real-time buyer alerts: Send Socket.IO updates to buyer-specific rooms when a broadcast is published.
  • Buyer notification centre: List notifications, retrieve the unclicked notification count, mark notifications as read or clicked, and delete notifications.
  • Delivery tracking: Maintain per-buyer notification state, including read status, click status, and soft deletion.
  • Automatic integration: The host application’s loaders register the add-on’s entities, migrations, controllers, worker, and plugin module.
  • Safe package removal: The host application is designed to continue running when the add-on is uninstalled.

Requirements

  • A compatible SpurtCommerce Community or Enterprise application.
  • A SpurtCommerce host application with the add-on loader integration expected by this package.
  • A reachable Redis-compatible datastore for the BullMQ queue backend used by the integration.
  • A configured Socket.IO server/instance in the host application’s runtime for real-time delivery.
The SpurtCommerce v6.0 release documents a backend baseline of Node.js 22.23.1 and TypeORM 0.3.26. Confirm the installed add-on version’s peer dependency requirements against the version of SpurtCommerce in your project before deployment.
Queue infrastructure: BullMQ needs a configured datastore connection for queues and workers. The package’s Redis connection settings must point to a reachable queue datastore. Use the connection configuration expected by the installed package; this guide does not assume environment-variable names that are not part of the package reference.

Installation

Run the following command from the root directory of your SpurtCommerce project:
For local development or testing from a source checkout:
After installation, the SpurtCommerce add-on loading mechanism discovers the package and integrates its components through the application loaders.

How the Add-on Works

The broadcast notification module combines persistent notification records, background job processing, and real-time buyer delivery. A typical broadcast lifecycle is:
  1. Create a broadcast: A vendor or administrator creates a notification with its content and optional image, announcement link, status, and scheduled publish date.
  2. Schedule processing: When publication is scheduled for a later time, the notification is queued with a delay.
  3. Process the job: The NotificationWorker consumes queued jobs and processes the broadcast. The worker supports multi-tenant processing and error resilience.
  4. Deliver to buyers: When the broadcast is published, the module sends real-time Socket.IO alerts to the relevant buyer rooms.
  5. Track buyer activity: Per-buyer records track whether a notification has been read, clicked, or soft-deleted.
  6. Expose buyer notifications: Buyers use the notification-list APIs to retrieve notifications and update their notification state.
The exact job payload, queue name, retry settings, socket event names, and room naming rules are implementation details of the installed package and are not specified by the public package reference.

API Overview

The add-on exposes two API groups.

Broadcast Notification API

Base route: /api/broadcast-notification/* This API group is used by vendors and administrators to manage broadcast notifications. Supported operations include:
  • Create a broadcast notification
  • List broadcast notifications
  • Retrieve notification details
  • Update a broadcast notification
  • Delete a broadcast notification
A broadcast notification can contain notification details, an image, a scheduled publish date, a status, and an announcement link.

Buyer Notification List API

Base route: /api/buyer-notification-list/* This API group provides buyer-facing notification management. Supported operations include:
  • Retrieve the buyer’s notification list
  • Retrieve the count of unclicked notifications
  • Mark a notification as read
  • Mark a notification as clicked
  • Delete a buyer notification
The buyer API operates on the buyer’s notification records so that read, clicked, and deletion states can be tracked for each recipient.
API reference note: The paths above are route namespaces. The package reference supplied for this guide does not include every individual HTTP method, endpoint path, request DTO, response schema, or authentication decorator. Use the controllers and the running API documentation for the exact endpoint contracts.

Data Models

The add-on uses two primary TypeORM entities. The main broadcast record represents the notification being published. The buyer record tracks each recipient’s interaction with that broadcast. This separation allows one broadcast to be delivered to multiple buyers while maintaining an individual notification state for each buyer.

Background Processing with BullMQ

The add-on uses BullMQ to process broadcast jobs asynchronously.

Queue responsibilities

  • Accept broadcast jobs for processing.
  • Support delayed jobs for scheduled notification publication.
  • Make jobs available to the worker when they are ready to run.

Worker responsibilities

The NotificationWorker is initialized by the Express loader and processes queued broadcast jobs. The package description identifies the worker as supporting:
  • Multi-tenant job processing
  • Scheduled/delayed broadcast handling
  • Error resilience during job processing
The queue and worker require access to the configured BullMQ datastore. Keep that service available to the SpurtCommerce application and configure the connection using the package’s supported settings.

Real-Time Updates with Socket.IO

When a broadcast is published, the add-on sends real-time alerts to buyer rooms through Socket.IO. The package exposes the following Socket.IO utilities:
These exports provide access to the Socket.IO integration exposed by the package. Use the package’s exported types and implementation to determine the correct initialization and access pattern in your host application. The package reference identifies buyer-room delivery but does not specify the client event name, event payload, room identifier format, or connection authentication contract. Those details should be taken from the installed package implementation before adding a client-side Socket.IO listener.

SpurtCommerce Loader Integration

The add-on is integrated into the host application through its loader lifecycle.

1. TypeORM loader

typeormLoader.ts registers the broadcast notification database components:
  • BroadcastNotification and BroadcastNotificationBuyer entities
  • The add-on’s database migrations
This makes the notification models available through the host application’s TypeORM DataSource.

2. Express loader

expressLoader.ts registers the API controllers and initializes the background worker: The worker is initialized as part of the Express loader integration described by the package.

3. Plugin loader

pluginLoader.ts registers BroadcastNotification in pluginModule. This makes the broadcast notification module available through the host application’s plugin registration mechanism.

Integration flow

The package is designed to be discovered and registered by the host application’s add-on loading mechanism. Manual registration should only be necessary when using a host application that does not include the expected loader integration.

Buyer Notification States

The BroadcastNotificationBuyer entity tracks the state of a broadcast for an individual buyer. These per-buyer states support the buyer notification list, unclicked notification count, and read/click/delete actions.

Uninstallation

To remove the add-on, run the following command from the SpurtCommerce project root:
The package is designed so that the host application can continue running when the broadcast notification add-on is absent. Broadcast notification APIs, queue processing, plugin registration, and real-time notification functionality provided by this package will no longer be available.
Database note: Uninstalling the npm package does not, by itself, mean that existing notification tables or records are automatically removed. Handle database cleanup separately and only after reviewing the add-on migrations and your data-retention requirements.

Operational Notes

  • Keep the BullMQ datastore reachable by the application and worker.
  • Ensure the host application’s Socket.IO server is initialized and available to the add-on.
  • Confirm the worker is initialized during application startup.
  • Verify scheduled publication using a test broadcast with a future publish time before enabling the feature in production.
  • Test tenant isolation to ensure a broadcast is processed for the intended tenant and its buyers.
  • Confirm buyer notification state changes independently for different recipients.

Summary

@spurtcommerce/broadcast-notification provides broadcast creation and management, scheduled publication, background processing, and real-time buyer notifications for SpurtCommerce. It uses TypeORM entities for broadcast and per-buyer tracking, BullMQ for queue processing, Socket.IO for buyer-room alerts, and the SpurtCommerce loader lifecycle for application integration.