https://github.com/usmantahirr/express-js-starter
https://github.com/usmantahirr/express-js-starter
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/usmantahirr/express-js-starter
- Owner: usmantahirr
- License: mit
- Created: 2025-03-03T13:09:28.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-03-28T14:25:19.000Z (8 months ago)
- Last Synced: 2025-03-28T14:30:35.152Z (8 months ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Infobip Notification Service
[](https://opensource.org/licenses/MIT)
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://expressjs.com/)
[](https://www.infobip.com/)
A robust TypeScript-based service for sending email and SMS notifications using Infobip's API. This service provides a simple and secure way to integrate Infobip's messaging capabilities into your applications.
## Features
- 📧 Send email notifications with optional file attachments
- 📱 Send SMS notifications
- 📎 File attachment support for emails (PDF, DOC, DOCX, JPG, PNG)
- 🔒 Input validation using Zod
- 📝 OpenAPI/Swagger documentation
- 🚦 Rate limiting
- 📊 Request logging
- 🔍 Error handling and monitoring
## Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- An Infobip account for both email and SMS notifications
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/infobip-notification-service.git
cd infobip-notification-service
```
2. Install dependencies:
```bash
npm install
# or
yarn install
```
3. Create a `.env` file:
```bash
cp .env.example .env
```
4. Configure your Infobip credentials in `.env`:
```
INFOBIP_API_KEY=your_api_key
INFOBIP_BASE_URL=your_base_url
INFOBIP_SENDER_EMAIL=your_verified_email
INFOBIP_SENDER_NUMBER=your_sender_number
```
## Configuration
### Infobip Setup
1. Create an Infobip account
2. Generate an API key
3. Verify your sender email
4. Get your sender number for SMS
5. Add the credentials to your `.env` file
## Running the Service
### Development
```bash
npm run dev
# or
yarn dev
```
### Production
```bash
npm run build
npm start
# or
yarn build
yarn start
```
The service will start on `http://localhost:3000` (or the port specified in your `.env` file).
## API Documentation
Once the service is running, you can access the API documentation at:
```
http://localhost:3000/api-docs
```
### Available Endpoints
#### Send Email
```
POST /notifications/email
Content-Type: multipart/form-data
{
"type": "email",
"recipient": "user@example.com",
"subject": "Important Notification",
"message": "This is an important email notification.",
"attachment": [file] // Optional
}
```
#### Send SMS
```
POST /notifications/sms
Content-Type: application/json
{
"type": "sms",
"recipient": "+1234567890",
"message": "Your verification code is: 123456"
}
```
## Rate Limiting
The service implements rate limiting to prevent abuse:
- 100 requests per minute per IP
- 1000 requests per hour per API key
## File Attachments
Email notifications support file attachments with the following specifications:
- Maximum file size: 2MB
- Supported formats: PDF, DOC, DOCX, JPG, PNG
- Only available for email notifications
## Error Handling
The service provides detailed error responses for various scenarios:
- 400: Invalid request parameters or validation errors
- 500: Internal server errors or service unavailability
## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
## Code of Conduct
This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
## Security
For security concerns, please see our [Security Policy](SECURITY.md).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
For support, please open an issue in the GitHub repository or contact the maintainers.
## Acknowledgments
- [Infobip](https://www.infobip.com/) for providing the messaging API
- [Express.js](https://expressjs.com/) for the web framework
- [TypeScript](https://www.typescriptlang.org/) for type safety
- [Zod](https://zod.dev/) for runtime type validation