FAQ - usmantahirr/infobip-notification-service GitHub Wiki
The Infobip Notification Service is a starter project that provides a simple and secure way to send email and SMS notifications using Infobip's API. It handles rate limiting, validation, error handling, and logging out of the box.
Current features:
- Email notifications with file attachments
- SMS notifications
- Rate limiting
- Input validation
- Error handling
- Logging
- Security headers
- CORS configuration
Planned features:
- Message queue integration
- Database integration
- Enhanced monitoring
- Caching layer
- Health check endpoints
- Node.js 18.x or later
- npm 9.x or later
- Infobip API credentials
- (Optional) PostgreSQL 14.x or later
- (Optional) Redis 6.x or later
-
Clone the repository:
git clone https://github.com/usmantahirr/infobip-notification-service.git cd infobip-notification-service
-
Install dependencies:
npm install
-
Set up environment:
cp .env.example .env # Edit .env with your credentials
Required variables:
# Application
NODE_ENV=development
PORT=3000
# Infobip
INFOBIP_API_KEY=your_api_key
INFOBIP_BASE_URL=your_base_url
INFOBIP_SENDER_EMAIL=your_verified_sender_email
INFOBIP_SENDER_NUMBER=your_sender_number
# Rate Limiting
RATE_LIMIT_WINDOW=60000
RATE_LIMIT_MAX_REQUESTS=100
Optional variables:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/notification_service
# Redis
REDIS_URL=redis://localhost:6379
Using curl:
curl -X POST http://localhost:3000/api/v1/notifications/email \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"recipient": "[email protected]",
"subject": "Welcome",
"message": "Welcome to our platform!"
}'
Using JavaScript/TypeScript:
const response = await fetch(
"http://localhost:3000/api/v1/notifications/email",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
recipient: "[email protected]",
subject: "Welcome",
message: "Welcome to our platform!",
}),
}
);
const data = await response.json();
Using curl:
curl -X POST http://localhost:3000/api/v1/notifications/sms \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"recipient": "+1234567890",
"message": "Your verification code is: 123456"
}'
Using JavaScript/TypeScript:
const response = await fetch("http://localhost:3000/api/v1/notifications/sms", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
recipient: "+1234567890",
message: "Your verification code is: 123456",
}),
});
const data = await response.json();
- 100 requests per minute per API key
- Rate limit headers are included in responses:
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset
Currently supported:
- DOC
- DOCX
- JPG
- PNG
Limitations:
- Max file size: 2MB
- Max 5 attachments per request
Code | Description |
---|---|
VALIDATION_ERROR |
Request validation failed |
AUTHENTICATION_ERROR |
Invalid or missing API key |
RATE_LIMIT_ERROR |
Rate limit exceeded |
INFOBIP_ERROR |
Error from Infobip API |
INTERNAL_ERROR |
Internal server error |
try {
await client.sendEmail({
recipient: "[email protected]",
subject: "Welcome",
message: "Welcome to our platform!",
});
} catch (error) {
if (error.code === "VALIDATION_ERROR") {
// Handle validation error
} else if (error.code === "RATE_LIMIT_ERROR") {
// Handle rate limit error
} else {
// Handle other errors
}
}
- API keys are stored in environment variables
- Never commit API keys to version control
- Use secure secret management in production
Current:
- API key authentication
- Rate limiting
- Security headers
- CORS configuration
- Input validation
Planned:
- JWT support
- OAuth2 integration
- API key rotation
- WAF integration
- DDoS protection
Current:
- Winston logging
- Basic error tracking
- Rate limit monitoring
Planned:
- Structured logging
- Log aggregation
- Log retention policies
- Prometheus metrics
- OpenTelemetry tracing
Current:
- Check application logs
- Monitor rate limits
- Track error rates
Planned:
- Prometheus metrics
- Grafana dashboards
- Health check endpoints
- Performance monitoring
- Distributed tracing
Options:
- Docker
- Kubernetes
- AWS ECS
- Manual deployment
See the Deployment Guide for detailed instructions.
Minimum:
- 1 CPU core
- 512MB RAM
- 1GB storage
Recommended:
- 2 CPU cores
- 1GB RAM
- 5GB storage
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
See the Contributing Guidelines for detailed instructions.
- Use TypeScript
- Follow existing code style
- Write tests
- Update documentation
- Use conventional commits
- GitHub Issues
- Documentation
- Community chat
- Email support
- Check existing issues
- Create a new issue
- Provide:
- Description
- Steps to reproduce
- Expected behavior
- Actual behavior
- Environment details
High Priority:
- Message queue integration
- Database integration
- Enhanced error handling
Medium Priority:
- Caching layer
- Health check endpoints
- Metrics collection
Low Priority:
- Advanced monitoring
- A/B testing
- Analytics dashboard
Last updated: March 2025