Skip to content

Latest commit

 

History

History
211 lines (144 loc) · 5.2 KB

README.md

File metadata and controls

211 lines (144 loc) · 5.2 KB

Logo

Newsletter Service

A newsletter service to send mails to all the subscribers of a particular topic.
· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Logo

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

  1. latestTime
  2. latestText
  3. latestTopic
  4. 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

(back to top)

Built With

Tools that were used in the process of making this microservice are:

(back to top)

Getting Started

To get a local copy up and running follow these simple steps:

Prerequisites

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

Installation

  1. Clone this project.

    git clone https://github.com/tanay13/newsletter-service.git
  2. Navigate to the cloned directory

    cd newsletter-service
  3. refer the .env-example file and enter all the environment variables there

  4. Enter the following command

    node app.js
  5. Start the scheduler script

    node script.js

(back to top)

Usage

  • 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"
    }

Roadmap

  • Add readme
  • Add scheduler script

See the open issues for a full list of proposed features (and known issues).

(back to top)

Improvements

  • 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

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - Tanay - [email protected]

Project Link: https://github.com/tanay13/newsletter-service

(back to top)

```

HEY THERE