Skip to content

Commit 05bd507

Browse files
gparlakovgparlakov-vmwaresashko9807
authored
add postman collection (#653)
* add postman collection - plus documentation and examples - the goal is to have new contributors be able to quickly test the api * chore: add link to readme - update the postman collection to include the address as a variable * default variables for local development --------- Co-authored-by: Georgi Parlakov <[email protected]> Co-authored-by: Aleksandar Petkov <[email protected]>
1 parent fec31a0 commit 05bd507

10 files changed

+133
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,7 @@ yarn prisma migrate deploy
378378
```
379379

380380
6. At this point you can re-deploy the `api-headless` deployment to trigger the standard flow of operation
381+
382+
## Postman
383+
384+
If you'd like to use Postman to query the API - see [postman doc](./tools/postman/readme.md)
86.6 KB
Loading

tools/postman/edit_example.png

68 KB
Loading

tools/postman/env_demo.png

78.3 KB
Loading

tools/postman/export.png

61.1 KB
Loading

tools/postman/get_tokens.png

97.2 KB
Loading

tools/postman/import.png

50.9 KB
Loading
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"info": {
3+
"name": "podkrepi.bg",
4+
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
5+
},
6+
"item": [
7+
{
8+
"name": "get token",
9+
"event": [
10+
{
11+
"listen": "test",
12+
"script": {
13+
"exec": [
14+
"// console.log('[INFO] Request: ', JSON.stringify(request))",
15+
"var data = JSON.parse(responseBody);",
16+
"// console.log('[info] response:', this)",
17+
"postman.setGlobalVariable(\"access_token\", data.accessToken);",
18+
"postman.setGlobalVariable(\"refresh_token\", data.refreshToken);"
19+
],
20+
"type": "text/javascript",
21+
"packages": {}
22+
}
23+
}
24+
],
25+
"request": {
26+
"auth": {
27+
"type": "noauth"
28+
},
29+
"method": "POST",
30+
"header": [
31+
{
32+
"key": "Content-Type",
33+
"value": "application/json"
34+
},
35+
{
36+
"key": "accept",
37+
"value": "*/*"
38+
}
39+
],
40+
"body": {
41+
"mode": "raw",
42+
"raw": "{\n \"email\": \"{{user}}\",\n \"password\": \"{{password}}\"\n}",
43+
"options": {
44+
"raw": {
45+
"language": "json"
46+
}
47+
}
48+
},
49+
"url": "{{podkrepi_address}}/api/v1/login"
50+
},
51+
"response": []
52+
},
53+
{
54+
"name": "User donations",
55+
"request": {
56+
"method": "GET",
57+
"header": [],
58+
"url": "{{podkrepi_address}}/api/v1/donation/user-donations"
59+
},
60+
"response": []
61+
}
62+
],
63+
"auth": {
64+
"type": "bearer",
65+
"bearer": {
66+
"token": "{{access_token}}"
67+
}
68+
},
69+
"event": [
70+
{
71+
"listen": "prerequest",
72+
"script": {
73+
"type": "text/javascript",
74+
"exec": [
75+
""
76+
]
77+
}
78+
},
79+
{
80+
"listen": "test",
81+
"script": {
82+
"type": "text/javascript",
83+
"exec": [
84+
""
85+
]
86+
}
87+
}
88+
],
89+
"variable": [
90+
{
91+
"key": "podkrepi_address",
92+
"value": "http://localhost:5010",
93+
"type": "string"
94+
},
95+
{
96+
"key": "user",
97+
"value": "[email protected]",
98+
"type": "string"
99+
},
100+
{
101+
"key": "password",
102+
"value": "$ecurePa33",
103+
"type": "string"
104+
}
105+
]
106+
}

tools/postman/readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Podkrepi.bg postman collection
2+
3+
## Getting started
4+
5+
- Get the postman app
6+
- Import the collection ![import image missing](./import.png)
7+
- Create an environment and add your username and password *ensure the password is a **secret** ![create an environment image missing](./env_demo.png)
8+
- 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)
9+
10+
Done - now you can make authenticated requests: ![example for authenticated request](./user_donations_example.png)
11+
12+
## Contributing to the collection
13+
14+
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)
15+
16+
- Edit in postman
17+
18+
![add new image missing](./add_new_via_duplicate.png)
19+
20+
![edit](./user_donations_example.png)
21+
22+
- Export and overwrite in the repo
23+
![export overwrite](./export.png)
56.9 KB
Loading

0 commit comments

Comments
 (0)