This project build using Spring Boot
To run the application, you need to install this application :
- Intellij IDEA (latest version)
- Redis (7.2.3 or above)
- Docker Desktop (4.26.0 or above)
-
Clone the git project on your local:
git clone https://github.com/DeveloperDel/gdsc-link-be.git
-
Go to the project directory directly:
cd gdsc-link-be
Note: Also, you need to make sure you're already open the docker desktop
-
Run this script to create the container in the docker:
docker-compose -d up
-
Run the container:
docker container start redis link-shortener-api
Note: To check if your container already started, you can check it in the docker desktop or just run this script in your prompt:
docker container ls
-
Finish, you can test the API in the postman to make sure it works properly.
This section outline all the API endpoint in this backend service:
For the base url, it depends on your localhost, usually in http://localhost:8080
Retrieve all the links from database
- Endpoint:
/links
- Method: GET
- Example OK Response:
{
"data": [
"Cloud",
"CloudVerse"
],
"error": false,
"message": "Links fetch successfully!",
"status": "OK"
}
Redirect into the original url
- Endpoint:
/{id}
- Method: GET
- Response: The response is in the form of HTML/document
Retrieve spesific link from database.
Note: {id}
is the short key after get shortened.
- Endpoint:
/link/{id}
- Method: GET
- Example OK Response:
{
"data": "https://example.com/your-long-url-that-you-test",
"error": false,
"message": "Long url fetch successfully!",
"status": "OK"
}
Retrieve QR Code from the spesific link.
Note: {id}
is the short key after get shortened.
- Endpoint:
/qr-code/{id}
- Method: GET
- Response: The response is in the form of media type (png).
Download QR Code of a spesific link.
Note: {id}
is the short key after get shortened.
- Endpoint:
/qr-code/{id}
- Method: GET
- Response: The response is in the form of media type (png).
Short your long url
- Endpoint:
/shorten
- Method: POST
- Example OK Response:
{
"data": {
"url": "<base-url>/<shortened-key>"
},
"error": false,
"message": "URL has been shortened successfully!",
"status": "CREATED"
}
Edit your short url key.
Note: {url}
is your old key url that will got edited.
- Endpoint:
/edit/{url}
- Method: PUT
- Example OK Response:
{
"data": {
"url": "<base-url>/<shortened-key>"
},
"error": false,
"message": "Url changed successfully!",
"status": "CREATED"
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.