@aryans_web/backend-toolkit
v0.0.4
Published
A list of useful functions.
Downloads
0
Maintainers
Readme
AlertClient
A TypeScript-based alert client for sending notifications via SMS, Email, and WhatsApp using different providers.
🚀 Features
- Supports multiple providers for SMS, Email, and WhatsApp.
- Fully typed with TypeScript for safety and autocompletion.
- Uses a provider map for extensibility.
- Works with Exotel, AWS SES, and VFirst (easily extendable).
📦 Installation
npm install @aryans_web/alert-clientor
yarn add @aryans_web/alert-client🛠️ Usage
1️⃣ Initialize the Alert Client
import AlertClient from '@aryans_web/alert-client'
const client = AlertClient<'sms' | 'email' | 'whatsapp'>({
sms: { provider: 'exotel', publishKey: 'your-key' },
email: {
provider: 'SES',
apiKey: 'your-api-key',
url: 'https://email-api.com'
},
whatsapp: { provider: 'vfirst', publishKey: 'your-key' }
})2️⃣ Send Alerts
Send an SMS
client.sms({ numbers: ['1234567890'], message: 'Hello!' }).then(console.log)Send an Email
client
.email({
from: '[email protected]',
to: ['[email protected]'],
subject: 'Test Email',
html: '<h1>Hello</h1>'
})
.then(console.log)Send a WhatsApp Message
client
.whatsapp({ numbers: ['1234567890'], message: 'Hello on WhatsApp!' })
.then(console.log)3️⃣ AWS SNS Publisher
Publish an SNS Message
import { snsPublisher } from '@aryans_web/alert-client'
snsPublisher({
topicArn: 'arn:aws:sns:us-east-1:123456789012:MyTopic',
message: 'Hello, this is an SNS message!'
}).then(console.log)4️⃣ Make HTTP Requests
Send a Custom HTTP Request
import { makeRequest } from '@aryans_web/alert-client'
makeRequest({
url: 'https://api.example.com/data',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key: 'value' })
}).then(console.log)🤝 Contributing
- Fork the repo
- Create a new branch (
git checkout -b feature-name) - Make changes and commit (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature-name) - Open a Pull Request
📜 License
MIT License © [Aryan Maurya]
