This a URL Shortener app which you can easily add to your project with little bit of configuration.
Here are some functionality of the app
- This app is created in Java Springboot.
- This app takes long url and return short url which you can easily fire on web and go to the long url.
- It uses role based authentication.
- For authentication it uses email and password which you have used while signing up.
- JWT Token is used for authentication.
- One cool thing --> you can customize the length of short url key length.
Here is the sample authentication api call diagram !!
- Sign up request [POST]
Status | Method | URL | Request | Header | Response |
200 | POST |
http://localhost:8080/auth/signup |
{
"name":"John Doe",
"email":"[email protected]",
"password":"john@1234"
} |
NO User added header |
{
"id":1,
"name":"John Doe",
"email":"[email protected]",
"password":"$2a$10$uhUIUmVWVnrBWx9rrDWhS."
} |
200 | POST |
http://localhost:8080/auth/login |
{
"email":"[email protected]",
"password":"john@1234"
} |
NO User added header |
{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJlbWFpbCI6ImpvaG5AZ21haWwuY29tIiwic
GFzc3dvcmQiOiJqb2huQDEyMzQifQ.ibVqO0r
g6jwJ3uIEvZAeH_Ecg7T2bDW2lXeRJr2stW4",
"username":"[email protected]"
} |
401 | POST |
http://localhost:8080/auth/login |
{
"email":"[email protected]",
"password":"john@12"
} |
NO User added header |
|
200 | POST |
http://localhost:8080/home/saveurl |
{
"originalUrl":"www.google.com"
} |
|
{
"id":1,
"originalUrl":"https://www.google.com",
"shortUrl":"24WnSpXt",
"creationDate":"2023-07-07T17:09:42.411",
"expirationDate":" 2023-11-04T17:09:42.411"
} |
200 | POST |
http://localhost:8080/home/get-user |
No body |
|
{
"id":1,
"name":"John Doe",
"email":"[email protected]",
"password":"$2a$10$uhUIUmVWVnrBWx9rrDWhS.",
"roles":["NORMAL"],
"urls": [
{
"id":1,
"originalUrl":"https://www.google.com",
"shortUrl":"24WnSpXt",
"creationDate":"2023-07-07T17:09:42.411",
"expirationDate":" 2023-11-04T17:09:42.411"
}
]
} |
-
Pull the docker image
docker pull surjendu104/url-shortener-images:latest
-
Run your mongodb server by running this in terminal
mongod
-
Run the container by setting enviorment variable
docker run \ -p 8080:8080 \ -e DB_HOST=<YOUR_IP_ADDRESS> \ -e DB_PORT=<MONGODB_PORT> \ -e DB_COLLECTION=<MONGODB_COLLECTION_NAME> \ -e JWT_SECRET=<JWT_SECRET> \ -e SHORT_URL_KEY_LENGTH=<LENGTH_YOU_WANT> \ surjendu104/url-shortener-images
docker run \ -p 8080:8080 \ -e DB_HOST=192.168.0.119 \ -e DB_PORT=27017 \ -e DB_COLLECTION=url_shortener \ -e JWT_SECRET="afafasfafafasfasfasfafacasdasfasxASFACASDFACASDFASFASFDAFASFASDAADSCSDFADCVSGCFVADXCcadwavfsfarvf" \ -e SHORT_URL_KEY_LENGTH=4 \ surjendu104/url-shortener-images