Repository navigation
Expand file tree
/
Copy pathrest-client.http
More file actions
53 lines (40 loc) · 1.42 KB
/
Copy pathrest-client.http
File metadata and controls
53 lines (40 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@base = http://localhost:3000/v1/api
@username = admin@example.com
@password = REPLACE_LOCALLY_DO_NOT_COMMIT
@accessToken = PASTE_ACCESS_TOKEN
@refreshToken = PASTE_REFRESH_TOKEN
@customerId = PASTE_UUID
@productId = PASTE_UUID
### Public health
GET {{base}}/health/ready
### Login; copy the two tokens from the response
POST {{base}}/auth/login
Content-Type: application/json
{"username":"{{username}}","password":"{{password}}"}
### Current profile
GET {{base}}/users/me
Authorization: Bearer {{accessToken}}
### Create a reader (admin only)
POST {{base}}/users
Authorization: Bearer {{accessToken}}
Content-Type: application/json
{"fullname":"Read Only Staff","username":"reader@example.com","password":"REPLACE_WITH_UNIQUE_PASSWORD","role":"reader"}
### Read products
GET {{base}}/products?limit=20
Authorization: Bearer {{accessToken}}
### Create an order (writer or admin)
POST {{base}}/orders
Authorization: Bearer {{accessToken}}
Idempotency-Key: example-order-001
Content-Type: application/json
{"customerId":"{{customerId}}","orderItems":[{"productId":"{{productId}}","quantity":2}]}
### Refresh ONCE, then replace both token variables
POST {{base}}/auth/refresh
Content-Type: application/json
{"refresh_token":"{{refreshToken}}"}
### Counts (admin only)
GET {{base}}/auth/counts
Authorization: Bearer {{accessToken}}
### Revoke this session, including its access token
POST {{base}}/auth/logout
Authorization: Bearer {{accessToken}}