A newsletter service to send mails to all the subscribers of a particular topic.
·
Report Bug
·
Request Feature
Table of Contents
While adding the newsletter content we are checking for latestTime key in the redis. If the new content time is lesser than the already stored latestTime key in redis then update all the keys in the redis, which are
- latestTime
- latestText
- latestTopic
- latestId - ID of the content document
The scheduler script runs on an interval of 1 minute and checks whether the current time is equal or greater than the latestTime stored in the redis.
If the above condition satisfies then the mail is sent to all the subscribers of the latestTopic. After sending the mail the sent content is deleted and the next latest deadline content is stored in the redis database
Tools that were used in the process of making this microservice are:
To get a local copy up and running follow these simple steps:
This is an example of how to list things you need to use the software and how to install them.
-
npm
npm install npm@latest -g
-
Clone this project.
git clone https://github.com/tanay13/newsletter-service.git
-
Navigate to the cloned directory
cd newsletter-service
-
refer the .env-example file and enter all the environment variables there
-
Enter the following command
node app.js
-
Start the scheduler script
node script.js
-
Post data to the following api to subscribe to a topic
http://localhost/api/addSubs
with body as :
{ "email": "[email protected]", "topic":"nutrition" }
-
Post data to the following api to add the newsletter content
http://localhost/api/addContent
with body as :
{ "contentText": "hey this is a newsletter", "contentTime":"2022-05-04T15:26:30.281Z", "topic": "nutrition" }
- Add readme
- Add scheduler script
See the open issues for a full list of proposed features (and known issues).
- Their can few minutes delay when dealing with two deadline with very less time intervaL
- Service not tested with some of the edge cases
- Server overloading can occur in case of high number of content
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - Tanay - [email protected]
Project Link: https://github.com/tanay13/newsletter-service
```HEY THERE