Skip to content

A simple URL Shortener API using Java Spring-Boot & GridDB

Notifications You must be signed in to change notification settings

alifruliarso/griddb-url-shortener

Repository files navigation

Building URL Shortener API using Java Spring-Boot & GridDB

Prerequisites:

Technology Stack

Back-end: Spring Boot, Maven
Database: GridDB 5.1.0

Run Application

Build the docker image:

docker compose build

Run the app with Docker Compose:

docker compose up

The following ports are exposed:

  • The application runs on port 8080.
  • Port 35729 allows the livereload plugin to listen to changes
  • Port 5005 makes the debugger available to the IDE

API Documentation

Swagger-UI available at http://localhost:8080/swagger-ui/index.html

Create a short URL

POST http://localhost:8080/api/urls

Postman

Create short URL

cURL

curl --request POST --url http://localhost:8080/api/urls --header 'content-type: application/json' \
--data '{"url": "https://www.javacodegeeks.com/2023/05/what-are-events-relation-to-api-calls.html"}' 

Response

{
  "url": "https://www.javacodegeeks.com/2023/05/what-are-events-relation-to-api-calls.html",
  "shortUrl": "HjlQjET"
}

Get original URL

GET http://localhost:8080/api/urls/{SHORT_URL}

Postman

Get original URL

cURL

curl --request GET --url http://localhost:8080/api/urls/HjlQjET

Response

{
  "url": "https://www.javacodegeeks.com/2023/05/what-are-events-relation-to-api-calls.html",
  "shortUrl": "HjlQjET"
}

Reference Documentation

tags: url-shortener shortener griddb spring-boot json-api docker live-reload inotify-tools