URL Shortener API built using Spring Boot, Kotlin, Selenium, MongoDB and Railway.
Click here for seeing the Swagger API documentation.
You can run it locally or use the deployment.
To use the application locally, follow these steps:
-
Clone the repository and navigate to the project directory.
git clone https://github.com/antonioalanxs/antolink.git cd backend
-
Install JDK 17.
sudo apt install openjdk-17-jdk
-
Install MongoDB.
sudo apt install mongodb
-
Start the MongoDB service.
sudo systemctl start mongodb
-
Create a new MongoDB database named
antolink
.mongo use antolink
-
Set Spring Boot environment variables
MONGODB_ROOT_USERNAME
,MONGODB_ROOT_PASSWORD
andAUTHORIZATION_CODE
. -
Run the application.
./gradlew bootRun
Now, the application is running on http://localhost:8080/api.
If you prefer to use the deployment, consume https://antolink-production.up.railway.app/api.
Creates a new link based on the provided LinkDTO
. Requires an authorization code header.
- Response 201: Link created successfully.
- Example:
{ "id": "66d1949cb4ea9d04d75f3f7a", "url": "https://www.youtube.com/", "shortCode": "YouTube", "usageCount": 0 }
- Example:
- Response 409: Conflict, the link already exists.
- Example:
{ "status": "CONFLICT", "detail": { "message": "{ url: \"https://x.com/\" } already exists" } }
- Example:
- Response 401: Invalid authorization code header.
- Example:
{ "status": "UNAUTHORIZED", "detail": { "message": "Invalid Authorization code header" } }
- Example:
Redirects to the URL associated with the provided short code.
- Response 301: Redirected successfully.
- Response 404: Link not found.
Retrieves a list of all links in LinkDTO
format.
- Response 200: Links retrieved successfully.
- Example:
[ { "url": "https://nova.elportaldelalumno.com/", "shortCode": "nova", "usageCount": 0 }, { "url": "https://www.stremio.com/", "shortCode": "stremio", "usageCount": 0 } ]
- Example:
For more detailed information, check the Swagger API documentation.
- Review of Spring Boot architecture
- Managing environment variables in Spring Boot
- Spring Boot annotations and aspects
- Configuring Spring Boot integration tests
- CI pipeline setup in GitHub Actions for integration tests
- Link verification and duplicate redirection prevention using Selenium
- Spring Boot/Kotlin and MongoDB Application Deployment
If you would like to contribute to the project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix (
git checkout -b feature/new-feature
). - Make your changes and commit them following the Conventional Commits format (
git commit -m 'feat: add new feature'
orfix: correct a bug
). - Push your branch to the remote repository (
git push origin feature/new-feature
). - Create a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.