medusajs-rules-notification-provider
v0.1.2
Published
A MedusaJS notification provider that forwards notifications based on rules.
Maintainers
Readme
MedusaJS Rules Notification Provider
A MedusaJS notification provider that forwards notifications based on rules. In development, it can override the recipient based on a regex pattern.
Installation
Using npm:
npm install medusajs-rules-notification-providerUsing yarn:
yarn add medusajs-rules-notification-providerUsage
Configure the provider in your MedusaJS project as follows:
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/medusa/notification",
options: {
providers: [
{
resolve: "@medusajs/medusa/notification-local",
id: "local",
options: {
channels: ["feed"],
},
},
{
resolve: "@medusajs/medusa/notification-sendgrid",
id: "sendgrid",
options: {
channels: ["email"],
api_key: process.env.SENDGRID_API_KEY,
from: process.env.SENDGRID_FROM,
},
},
{
resolve: "medusajs-rules-notification-provider",
id: "rules-notification",
options: {
channels: ["rules"],
forwardChannel: "email",
env: "development",
toMatchPattern: "^[A-Z]+@example\\.com$",
overrideToOnMatch: "[email protected]",
overrideToOnMismatch: "[email protected]"
}
}
]
}
}
}Options
The provider supports the following configuration options:
forwardChannel (string, required):
The channel to which notifications will be forwarded.env (string, optional):
The runtime environment (e.g., "development" or "production"). If not provided, it falls back toprocess.env.NODE_ENV.toMatchPattern (string, optional):
A regex pattern to test thenotification.tovalue in development mode.overrideToOnMatch (string, optional):
The override value fornotification.toif it matches the regex pattern.overrideToOnMismatch (string, optional):
The override value fornotification.toif it does not match the regex pattern.
License
MIT License
