diff --git a/README.md b/README.md index f3079fa54..c0aa14322 100644 --- a/README.md +++ b/README.md @@ -378,3 +378,7 @@ yarn prisma migrate deploy ``` 6. At this point you can re-deploy the `api-headless` deployment to trigger the standard flow of operation + +## Postman + +If you'd like to use Postman to query the API - see [postman doc](./tools/postman/readme.md) diff --git a/tools/postman/add_new_via_duplicate.png b/tools/postman/add_new_via_duplicate.png new file mode 100644 index 000000000..cc876201c Binary files /dev/null and b/tools/postman/add_new_via_duplicate.png differ diff --git a/tools/postman/edit_example.png b/tools/postman/edit_example.png new file mode 100644 index 000000000..c75deb590 Binary files /dev/null and b/tools/postman/edit_example.png differ diff --git a/tools/postman/env_demo.png b/tools/postman/env_demo.png new file mode 100644 index 000000000..76d6255f9 Binary files /dev/null and b/tools/postman/env_demo.png differ diff --git a/tools/postman/export.png b/tools/postman/export.png new file mode 100644 index 000000000..a21d075b0 Binary files /dev/null and b/tools/postman/export.png differ diff --git a/tools/postman/get_tokens.png b/tools/postman/get_tokens.png new file mode 100644 index 000000000..c543fb51f Binary files /dev/null and b/tools/postman/get_tokens.png differ diff --git a/tools/postman/import.png b/tools/postman/import.png new file mode 100644 index 000000000..5ef74e161 Binary files /dev/null and b/tools/postman/import.png differ diff --git a/tools/postman/podkrepi.bg.postman_collection.json b/tools/postman/podkrepi.bg.postman_collection.json new file mode 100644 index 000000000..7d19b3f59 --- /dev/null +++ b/tools/postman/podkrepi.bg.postman_collection.json @@ -0,0 +1,106 @@ +{ + "info": { + "name": "podkrepi.bg", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "get token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// console.log('[INFO] Request: ', JSON.stringify(request))", + "var data = JSON.parse(responseBody);", + "// console.log('[info] response:', this)", + "postman.setGlobalVariable(\"access_token\", data.accessToken);", + "postman.setGlobalVariable(\"refresh_token\", data.refreshToken);" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"{{user}}\",\n \"password\": \"{{password}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "{{podkrepi_address}}/api/v1/login" + }, + "response": [] + }, + { + "name": "User donations", + "request": { + "method": "GET", + "header": [], + "url": "{{podkrepi_address}}/api/v1/donation/user-donations" + }, + "response": [] + } + ], + "auth": { + "type": "bearer", + "bearer": { + "token": "{{access_token}}" + } + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "podkrepi_address", + "value": "http://localhost:5010", + "type": "string" + }, + { + "key": "user", + "value": "admin@podkrepi.bg", + "type": "string" + }, + { + "key": "password", + "value": "$ecurePa33", + "type": "string" + } + ] +} diff --git a/tools/postman/readme.md b/tools/postman/readme.md new file mode 100644 index 000000000..8ad98c976 --- /dev/null +++ b/tools/postman/readme.md @@ -0,0 +1,23 @@ +# Podkrepi.bg postman collection + +## Getting started + +- Get the postman app +- Import the collection ![import image missing](./import.png) +- Create an environment and add your username and password *ensure the password is a **secret** ![create an environment image missing](./env_demo.png) +- Get the tokens via the `get token` request (it will use the postman env variables from previous step and store a access_token in postman global variables) ![authenticate image missing](./get_tokens.png) + +Done - now you can make authenticated requests: ![example for authenticated request](./user_donations_example.png) + +## Contributing to the collection + +The way to contribute is edit in a postman editor and then export it (Postman stores the collections in a db somewhere and there's no trivial way to have it store it where we need it - in the repo) + +- Edit in postman + +![add new image missing](./add_new_via_duplicate.png) + +![edit](./user_donations_example.png) + +- Export and overwrite in the repo +![export overwrite](./export.png) diff --git a/tools/postman/user_donations_example.png b/tools/postman/user_donations_example.png new file mode 100644 index 000000000..318fd09cb Binary files /dev/null and b/tools/postman/user_donations_example.png differ