From b2d40e5401a1f852076da3096448fcd8fe0d75e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Sep 2025 03:12:37 +0300 Subject: [PATCH] docs: updated README and added Postman collections for local adn deployed --- README.md | 32 ++ ...shortener_deployed_postman_collection.json | 273 ++++++++++++++++++ ...nkshortener_local_postman_collection.json} | 0 3 files changed, 305 insertions(+) create mode 100644 docs/postman/Linkshortener_deployed_postman_collection.json rename docs/postman/{Linkshortener_postman_collection.json => Linkshortener_local_postman_collection.json} (100%) diff --git a/README.md b/README.md index 30f3e25..9fc61bf 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,38 @@ OpenAPI JSON: | GET | `/health` | Health check | | GET | `/api/links/{code}` | Redirect by short code | +--- +## Deployment + +The project is automatically deployed to a remote server via **GitHub Actions**. +Every merge/push to the `master` branch triggers the workflow (`.github/workflows/deploy.yml`) which: + +1. Connects to the server (`user@ip` via SSH) +2. Executes the `deploy.sh` script +3. Updates the repository (`git pull origin master`) +4. Rebuilds Docker containers and restarts the application (`docker compose up -d --build`) + +**Note:** Private keys for GitHub Actions are stored in GitHub Secrets and **are not published** in the README. + +--- + +## Postman Collections + +There are two collections in the `postman/` folder: + +- `Linkshortener_local_postman_collection.json` – for local version (`http://localhost:8080`) +- `Linkshortener_deployed_postman_collection.json` – for the production server (`http://91.225.7.129:8080`) + +To use the collections, import them into Postman. + +--- + +## Swagger (Production) + +API documentation for the production server is available here: +[Go to Swagger](http://91.225.7.129:8080/swagger-ui/index.html) + + --- ## What this app can do diff --git a/docs/postman/Linkshortener_deployed_postman_collection.json b/docs/postman/Linkshortener_deployed_postman_collection.json new file mode 100644 index 0000000..3e70256 --- /dev/null +++ b/docs/postman/Linkshortener_deployed_postman_collection.json @@ -0,0 +1,273 @@ +{ + "info": { + "_postman_id": "f71610e2-9b1d-48a4-9a86-3807272a7e18", + "name": "Linkshortener(fromLoclhost)", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "43658247" + }, + "item": [ + { + "name": "Health", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://91.225.7.129:8080/health", + "protocol": "http", + "host": [ + "91.225.7.129" + ], + "port": "8080", + "path": [ + "health" + ] + } + }, + "response": [] + }, + { + "name": "Register User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"username\": \"testuser1\",\r\n \"password\": \"Password123\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/auth/register", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "auth", + "register" + ] + } + }, + "response": [] + }, + { + "name": "Login User", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const response = pm.response.json();\r", + "pm.collectionVariables.set(\"token\", response.token);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"username\": \"testuser\",\r\n \"password\": \"Password123\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/auth/login", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "auth", + "login" + ] + } + }, + "response": [] + }, + { + "name": "Add link", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0dXNlcjEiLCJpYXQiOjE3NTc2MTY3ODAsImV4cCI6MTc1NzYyMDM4MH0.JPOQIjd8q4aiV6vYI5sApmS7RVmzmdn6j8dcyBTdmwU", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"url\": \"https://github.com/RuslanLomaka/GoitJavaDevProjLinkShortener\"\r\n}" + }, + "url": { + "raw": "{{baseUrl}}/auth/api/links", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "auth", + "api", + "links" + ] + } + }, + "response": [] + }, + { + "name": "Forward by link", + "request": { + "method": "GET", + "header": [] + }, + "response": [] + }, + { + "name": "My links", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0dXNlcjEiLCJpYXQiOjE3NTc2MTkwMzMsImV4cCI6MTc1NzYyMjYzM30.5K9GRMiGptBQgyIxOGMWSMmJeADu80kIkPbeL_KSPac", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/api/links/my_all_links", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "links", + "my_all_links" + ] + } + }, + "response": [] + }, + { + "name": "Delete link by id", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0dXNlcjEiLCJpYXQiOjE3NTc2MTkwMzMsImV4cCI6MTc1NzYyMjYzM30.5K9GRMiGptBQgyIxOGMWSMmJeADu80kIkPbeL_KSPac", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/api/links/delete/8d426643-ed03-42cf-9eb5-20d25800223c", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "links", + "delete", + "8d426643-ed03-42cf-9eb5-20d25800223c" + ] + } + }, + "response": [] + }, + { + "name": "JSON API docs", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://91.225.7.129:8080/v3/api-docs", + "protocol": "http", + "host": [ + "91.225.7.129" + ], + "port": "8080", + "path": [ + "v3", + "api-docs" + ] + } + }, + "response": [] + }, + { + "name": "Refresh Token", + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0dXNlciIsImlhdCI6MTc1NzUzMDk0MSwiZXhwIjoxNzU4MTM1NzQxfQ.3dtnvIqBNaGGpPF6qIP3BkXE85gS4HLC74R7kQmAxho", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/auth/refresh", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "auth", + "refresh" + ] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "http://91.225.7.129:8080", + "type": "string" + }, + { + "key": "token", + "value": "", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/docs/postman/Linkshortener_postman_collection.json b/docs/postman/Linkshortener_local_postman_collection.json similarity index 100% rename from docs/postman/Linkshortener_postman_collection.json rename to docs/postman/Linkshortener_local_postman_collection.json