-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.http
More file actions
99 lines (75 loc) · 2.41 KB
/
Copy pathclient.http
File metadata and controls
99 lines (75 loc) · 2.41 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
### Health check
GET http://localhost:8080/api/healthz HTTP/1.1
// --- USERS ---
### Create user
POST http://localhost:8080/api/users HTTP/1.1
Content-Type: application/json
{
"email": "lane@example.com",
"password": "04234"
}
### Login — returns access token + refresh token
POST http://localhost:8080/api/login HTTP/1.1
Content-Type: application/json
{
"email": "lane@example.com",
"password": "04234"
}
### Update user email + password — requires access token
PUT http://localhost:8080/api/users HTTP/1.1
Content-Type: application/json
Authorization: Bearer PASTE_ACCESS_TOKEN_HERE
{
"email": "new@example.com",
"password": "newpassword"
}
### Refresh — get new access token using refresh token
POST http://localhost:8080/api/refresh HTTP/1.1
Authorization: Bearer PASTE_REFRESH_TOKEN_HERE
### Revoke — invalidate refresh token
POST http://localhost:8080/api/revoke HTTP/1.1
Authorization: Bearer PASTE_REFRESH_TOKEN_HERE
### Reset (dev only)
POST http://localhost:8080/admin/reset HTTP/1.1
// --- WEBHOOKS ---
### Polka webhook — upgrade user to Chirpy Red
POST http://localhost:8080/api/polka/webhooks HTTP/1.1
Content-Type: application/json
Authorization: ApiKey PASTE_POLKA_KEY_HERE
{
"event": "user.upgraded",
"data": {
"user_id": "PASTE_USER_ID_HERE"
}
}
### Polka webhook — unknown event (ignored, returns 204)
POST http://localhost:8080/api/polka/webhooks HTTP/1.1
Content-Type: application/json
Authorization: ApiKey PASTE_POLKA_KEY_HERE
{
"event": "user.something_else",
"data": {
"user_id": "PASTE_USER_ID_HERE"
}
}
// --- CHIRPS ---
### Create chirp — user_id comes from JWT
POST http://localhost:8080/api/chirps HTTP/1.1
Content-Type: application/json
Authorization: Bearer PASTE_ACCESS_TOKEN_HERE
{
"body": "Hello, world!"
}
### Get all chirps — default asc
GET http://localhost:8080/api/chirps HTTP/1.1
### Get all chirps — descending
GET http://localhost:8080/api/chirps?sort=desc HTTP/1.1
### Get chirps by author
GET http://localhost:8080/api/chirps?author_id=PASTE_USER_ID_HERE HTTP/1.1
### Get chirps by author — descending
GET http://localhost:8080/api/chirps?author_id=PASTE_USER_ID_HERE&sort=desc HTTP/1.1
### Get chirp by ID
GET http://localhost:8080/api/chirps/PASTE_CHIRP_ID_HERE HTTP/1.1
### Delete chirp by ID — requires access token + ownership
DELETE http://localhost:8080/api/chirps/PASTE_CHIRP_ID_HERE HTTP/1.1
Authorization: Bearer PASTE_ACCESS_TOKEN_HERE