Contents
Back-End APIs that handle creation, management, deletion of cryptocurrency’s price email-based alerts.
- User authentication at the endpoints using JWT tokens and BCrypt.
- A caching layer is present for the “fetch all alerts” endpoints which using Redis.
- When the price of the Crypto reaches the price specified by the user, an email will be send to user that set the alert at the price using SendGrid.
- It uses RabbitMQ as a message broker for the task to send emails.
- Paginated and filtered response of the “fetch all alerts” route.
- Install and run MongoDB locally.
- Install and run Redis locally or use Redis as a service with Redis cloud.
- Create an account on Cloudamqp to use RabbitMQ as a service.
- Create an account on SendGrid.
- Clone this repository on your local machine.
- Install all the dependencies using node package manager.
- Create a
.envfile in the root directory and store the following information in this file: _ SendGrid API key and user email address _ If MongoDB Atlas is used then store the URL else connect to the MongoDB local host _ If Redis is used as a service then store the URL else connect to the local host _ Store the URL of Cloudamqp * Access and Refresh tokens for JSON web token These variables should be specified as
DB_URL=<mongodbURL>
ACCESS_TOKEN_SECRET=<accesToken>
REFRESH_TOKEN_SECRET=<refreshToken>
SendGrid=<apiKey>
SendGridFrom=<userEmail>
AmqpURL=<cloudURL>
RedisURL=<redisURL>
- Run the following commands in different terminals to start the server:
node server.js
node workers/sendAlert.js
node utilities/consumer.js
- Registration
- Send a post request to
http://localhost:3000/users/registerwith request body containing JSON object with the name, email, and password key of the user.
- Send a post request to
- LogIn
- Send a post request to
http://localhost:3000/users/loginwith request body containing JSON object with the email and password key of the user. - In response, the user will receive the access and refresh tokens.
- Also, the access token will be expired after 30 minutes, therefore, to get a new access token, the user should send a post request to
http://localhost:3000/users/tokenwith request body containing JSON object with the refresh token received at the time of login.
- Send a post request to
- Creating Alerts
- Send a post request to
http://localhost:3000/alerts/createwith query parameter price set to the price at which user wants to get an alert. - Also, access token received at the login route must be added as the Authorization Bearer type token.
- Send a post request to
- Fetching all Alerts
- Send a get request to
http://localhost:3000/alertswith query parameter page set to the value of the page of which the user wants to get alerts. - Also, access token received at the login route must be added as the Authorization Bearer type token.
- Additionally, user can also add a status query parameter to filter alerts based on their status of "Created", "Triggered", and "Deleted".
- The response will contain alerts with the alert ID, status, price, and user email ID information.
- Send a get request to
- Deleting Alerts
- Send a delete request to
http://localhost:3000/alerts/deletewith query parameter id having the value set to the ID of the alert. - Also, access token received at the login route must be added as the Authorization Bearer type token.
- Send a delete request to
- LogOut
- Send a delete request to
http://localhost:3000/users/logoutwith request body containing JSON object with the email of the user.
- Send a delete request to