alepha@docs:~/docs/packages/alepha/api$
cat notifications.md
1 min read
Last commit:

#Alepha - Api Notifications

#Installation

Part of the alepha package. Import from alepha/api/notifications.

npm install alepha

#Overview

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.

#API Reference

#Primitives

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.

#$notification()

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.

ts
 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}
On This Page
No headings found...
ready
mainTypeScript
UTF-8packages_alepha_api_notifications.md