@chelseaapps/notification documentation
Send email, SMS and push* notifications to users on Chelsea Apps projects.
Push notifications are not yet implemented
Installation
The project is hosted on our private npm registry, so to install simply run
npm
npm i @chelseaapps/notificationyarn
yarn add @chelseaapps/notificationRequirements
The Email, SMS and Push methods are all sent using a separate process, via Redis. You must have a Redis server running locally on the default host & port (for now, will add Redis config parameters to the options in the future).
Configuration
The module can be imported either globally or restricted to a single module scope. The default option is global, as this allows the module to be used across multiple modules without having to configure it multiple times.
Config options
Option
Description
Example
isGlobal
Register the module globally across all modules in the app
true
email > host
SMTP email host
email-smtp.eu-west-2.amazonaws.com
email > port
SMTP email port
465
email > user
SMTP user
AKIAZQJAQWWNH7QEHL4O
email > password
SMTP password
****
sms > aws > region
AWS region used for SNS
eu-west-2
sms > aws > accessKeyId
AWS access key ID with SNS IAM privileges
AKIAZQJAQWWNEGDK5YGP
sms > aws > secretAccessKey
Corresponding AWS secret key
****
sender
SMS sender ID (max 12 characters)
FExchange
messageType
Type of message being sent (Transactional or Promotional)
Transactional
The module can be configured in two ways:
Regular
Asynchronous
Regular config
Import the module into the module in which you wish to register, and call the static register function.
Asynchronous config
The module can also be registered asynchronously to create the module dynamically, fetching configuration details from an external source (such as an environment variable).
Usage
Import the NotificationService into a module using the Nest depedency injection mechanism.
Where TestNotification is a class extending the INotification interface (see below).
Mustache & MJML
Normally we use Mustache to template emails and MJML to compile to HTML. This makes it easier to send personalised, responsive emails. However these are not required. The NotificationService expects the body or emailBody parameters to be plain text or HTML, so any templating and email markup libraries can be used (provided they compile to HTML).
Documentation
Detailed documentation of the methods can be found in the documentation folder. They can be hosted locally by running
from the documentation folder.
Was this helpful?