Part of the alepha package. Import from alepha/api/notifications.
npm install alepha
Provides notification management API endpoints for Alepha applications.
This module includes notification sending, retrieval, status tracking, and user notification preferences management.
Requires AlephaSms module to be loaded for SMS notifications.
Primitives are functions that define and configure various aspects of your application. They follow the convention of starting with $ and return configured primitive instances.
For more details, see the Primitives documentation.
Creates a notification primitive for managing email/SMS notification templates.
Provides type-safe, reusable notification templates with multi-language support, variable substitution, and categorization for different notification channels.
1class NotificationTemplates { 2 welcomeEmail = $notification({ 3 name: "welcome-email", 4 category: "onboarding", 5 schema: t.object({ username: t.text(), activationLink: t.text() }), 6 email: { 7 subject: "Welcome to our platform!", 8 body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}` 9 }10 });11 12 async sendWelcome(user: User) {13 await this.welcomeEmail.push({14 variables: { username: user.name, activationLink: generateLink() },15 contact: user.email16 });17 }18}