Skip to content

CyberZujo/URLShortener-nodejs-rabbitmq-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

URLShortener

Hi
URL Shortener services.

Inside you will find two projects representing two services.
Follow the instructions on how to get the project up and running.
I would recommend testing it on MacOS also, in case rabbitmq causes some problems on Windows

  1. Clone the project in some folder on your machine
  2. Navigate to Shortify.Management using command line tools and run:
    • npm install
      This will restore node dependencies
  3. Repeat step 2 for Shortify.Redirection
  4. Navigate to Shortify.Management using command line tools
  5. After you're inside the Shortify.Management run the following command:
    • docker-compose -f docker-compose.yml up
  6. If it is all successfull , check the following ports: -localhost:8080 (phpmyadmin) -localhost:15672 (rabbitmq management)
  7. Credentials for phpmyadmin :
    • Username: root
    • Password: root
  8. Credentials for rabbitmq management :
    • Username: guest
    • Password: guest
  9. Navigate to both Shortify.Management and Shortify.Redirection and type the following in terminal:
    • npm start
      This should start both of the applications with some basic information in the console

If it's all working, you should now have all your containers and services up and running and you should be able to access admin panels for mysql and rabbitmq.

Following are instructions on how to test the application itself.
All requests are made using Postman

  1. Open Postman and in the request window select the request type as POST and in the url bar paste the following URL
  2. Underneath the url bar there is a Body tab for sending the data withing the request Select the "raw" content format and on the left dropdown select "application/json" as content type and send followin json:
  3. After you click the Send button, you will get formatted response containing Id, URL that you sent, and short representation of the url
  4. ShortURL contains the url of the Redirection service so you can click on the link from response, and it will open new tab in postman Example: http://localhost:4000/redirection/A1a3
  5. You can click Send button again and the request will be sent to the Redirection service

For the response you will get the page itself because of the redirection from the application, you can see it in the preview section of the body response, or just paste the short url in the browser and send the request again.

Testing the DELETE method on the management service

  1. Repeat step 1 for the POST request on management service, just instead of POST type select DELETE from dropdown
  2. For the body of request, please send following json:
    • { "id": take_Id_from_db} You can check the records in the database on phpmyadmin on localhost:8080
  3. Send the request

As response of the DELETE request, you will get the Id, Hash, and property which indicates that the record has been deleted. Hash part is important for Redis, since we're deleting values by the key which is hash part of the URL.

As you're sending these requests, you can notice info messages in the console of both running services.

Rate limiter
Our Redirection API has been limited to 10 requests for 120 seconds window time. Try repeating request and when it passes 10th request, you will get the 429 response from the API.

As in POST request for the management service, please try to send url with https, since redirection is going outside of our domain.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published