nest-notibox
v1.0.7
Published
A NestJS notification module for Slack, Telegram, and Discord
Maintainers
Readme
📢 Notibox
A NestJS notification library supporting Slack, Telegram, and Discord with retry and fallback features.
Slack / Telegram / Discord 알림 전송을 지원하는 NestJS 기반의 알림 통합 모듈입니다.
🚀 Installation / 설치
npm install notibox📦 Purpose / 사용 목적
- ✅ Unified interface to send messages to Slack, Telegram, and Discord
Slack / Telegram / Discord에 하나의 서비스로 알림을 전송 - 🔁 Retry logic to handle transient failures
일시적인 네트워크 오류를 자동으로 재시도 - 🧩 Fallback channels when primary fails
메인 채널 전송 실패 시 예비 채널로 자동 전환
🛠 Setup & Usage / 설정 및 사용 방법
1. Register NotiboxModule / NotiboxModule 등록
// app.module.ts
import { Module } from '@nestjs/common';
import { NotiboxModule } from 'notibox';
@Module({
imports: [
NotiboxModule.forRoot(), // No setup needed (기본 설정만으로 사용 가능)
],
})
export class AppModule {}Or with ConfigService + .env (또는 환경변수 기반 설정)
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
NotiboxModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
defaultSlackWebhookUrl: config.get('SLACK_WEBHOOK'),
defaultTelegram: {
botToken: config.get('TELEGRAM_TOKEN'),
chatId: config.get('TELEGRAM_CHAT_ID'),
},
defaultDiscordWebhookUrl: config.get('DISCORD_WEBHOOK'),
}),
}),
],
})
export class AppModule {}2. Inject & Use / 서비스 주입 및 사용
import { NotiboxService } from 'notibox';
constructor(private readonly notibox: NotiboxService) {}🔔 Usage Examples / 사용 예시
Slack
await this.notibox.sendSlack({
message: '📢 New order received!',
webhookUrl: 'https://hooks.slack.com/services/AAA/BBB/CCC',
retryCount: 3,
retryDelay: 1000,
fallbackWebhookUrl: 'https://hooks.slack.com/services/XXX/YYY/ZZZ',
});Telegram
await this.notibox.sendTelegram({
message: '📬 New user message arrived.',
botToken: '123456:bot-token',
chatId: '987654321',
fallback: {
botToken: '111111:other-bot',
chatId: '222222222',
},
});Discord
await this.notibox.sendDiscord({
message: '🚨 System error occurred!',
webhookUrl: 'https://discord.com/api/webhooks/abc123',
retryCount: 2,
retryDelay: 500,
});✅ Features Summary / 주요 기능 요약
| Feature | 설명 |
|--------|------|
| Unified Messaging | Slack / Telegram / Discord 통합 전송 |
| Retry Support | 재시도 기능으로 실패 복구 |
| Fallback Support | 예비 채널 전송 지원 |
| NestJS-native | NestJS 전용 모듈로 손쉽게 연동 가능 |
| .forRoot(), .forRootAsync() | 설정/환경변수 기반 구성 지원 |
📝 License / 라이선스
MIT
