Skip to content

ShauryaAg/VaccineNotifierAPI

Repository files navigation

VaccineNotifier

Vaccine Notifier API

This API allows users to subscribe to notification emails, if any vaccine slot is empty within their pincode.

Features

  • Users can subscribe for emails about vaccine availability
  • Email confirmation before subscribing to avoid spamming
  • Unsubscribe button in emails if user wishes to do so.
  • Cron Job runs every 1.5 hours to check for availability

Setup locally

  • Clone the repo using git clone https://github.com/ShauryaAg/VaccineNotifierAPI.git
  • Move into the project folder cd VaccineNotifierAPI/
  • Create a .env file in the project folder
CURRENT_HOST=<Your Deployment Link>
PORT=<PORT>
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
POSTGRES_HOST=postgres
SECRET=<Secret>
SENDGRID_API_KEY=<Your Key>
Using Docker VaccineNotifier
  • Run using sudo docker-compose up

OR

Using Golang VaccineNotifier
  • Install the dependecies using go mod download
  • Run using go run server.go

Deployment

  • This can't be deployed on Heroku since Cowin public API doesn't allow requests from anywhere outside India (at least from my experience) and Heroku doesn't allow us to choose Indian region.

  • Deploy on AWS / Digital Ocean / GCP / Any other cloud service

  • It is currently deployed on AWS

Endpoint Usage

Auth

  • /api/auth/register

    • Allowed Methods: POST
    • Accepted Fields: {name, email, password, age, pincode, preferredVaccine}
    • Returns: User Details
    • Sends a confirmation mail to the user
  • /api/auth/login

    • Allowed Methods: POST
    • Accepted Fields: {email, password}
    • Returns: {id, email, token}

      Make sure email is confirmed before logging in

  • /api/auth/user

    • Allowed Methods: GET PATCH

      • GET

        • Authorization: Bearer <Token>
        • Returns: User details after update
      • PATCH

        • Accepted Fields: User details to be updated
        • Returns: User details after update
  • api/auth/unsub

    • Allowed Methods: POST
    • Authorization: Bearer <Token>
    • Unsubscribe user from getting notification mails
  • api/auth/reset_password

    • Allowed Methods: POST
    • Accepted Fields: {email}
    • Sends a password reset email to the user

Notification

  • api/notifyall

    • Allowed Methods: GET
    • Sends a notification email to all the registered users

      This endpoint was created for testing purposes and doesn't work in production

Token

  • /t/<token>

    • Allowed Methods: GET
    • View to verify email confirmation token
  • /u/<token>

    • Allowed Methods: GET
    • View to unsubscribe user from notification emails
  • /f/<token>

    • Allowed Methods: GET POST
    • View to reset user password

About

An API written in Golang to subscribe to emails for the availability of the Covid-19 vaccine.

Topics

Resources

License

Stars

Watchers

Forks