@forinda/kickjs-notifications
v1.3.2
Published
Multi-channel notifications for KickJS — email, Slack, Discord, webhook, custom
Maintainers
Keywords
Readme
@forinda/kickjs-notifications
Multi-channel notifications for KickJS — email, Slack, Discord, webhook, and custom channels.
Install
# Using the KickJS CLI (recommended)
kick add notifications
# Manual install
pnpm add @forinda/kickjs-notificationsFeatures
NotificationAdapter— lifecycle adapter that registers the notification serviceNotificationService— injectable service for dispatching notifications- Built-in channels:
EmailChannel,SlackChannel,DiscordChannel,WebhookChannel,ConsoleChannel NOTIFICATIONStoken for DI injection- Pluggable
NotificationChannelinterface for custom transports
Quick Example
import {
NotificationAdapter,
NotificationService,
SlackChannel,
EmailChannel,
ConsoleChannel,
NOTIFICATIONS,
} from '@forinda/kickjs-notifications'
import { Inject, Service } from '@forinda/kickjs-core'
bootstrap({
modules,
adapters: [
new NotificationAdapter({
channels: [
new SlackChannel({ webhookUrl: process.env.SLACK_WEBHOOK! }),
new EmailChannel({ mailer }),
new ConsoleChannel(),
],
}),
],
})
// Send notifications from any service
@Service()
class AlertService {
@Inject(NOTIFICATIONS) private notifications!: NotificationService
async alertTeam(message: string) {
await this.notifications.send({
channels: ['slack', 'email'],
subject: 'Alert',
body: message,
to: '[email protected]',
})
}
}Documentation
License
MIT
