murmur.http384 lines, 9.2 KB
| 1 | @base = http://localhost:8080 |
| 2 | |
| 3 | ### Sign up |
| 4 | # @name alice |
| 5 | POST {{base}}/users |
| 6 | Content-Type: application/json |
| 7 | |
| 8 | { "handle": "alice" } |
| 9 | |
| 10 | ### The same handle again |
| 11 | # @name taken |
| 12 | POST {{base}}/users |
| 13 | Content-Type: application/json |
| 14 | |
| 15 | { "handle": "alice" } |
| 16 | |
| 17 | ### A second user |
| 18 | # @name bob |
| 19 | POST {{base}}/users |
| 20 | Content-Type: application/json |
| 21 | |
| 22 | { "handle": "bob" } |
| 23 | |
| 24 | ### Alice posts |
| 25 | # @name first |
| 26 | POST {{base}}/posts |
| 27 | Authorization: Bearer {{alice.response.body.token}} |
| 28 | Content-Type: application/json |
| 29 | |
| 30 | { "body": "hello, murmur" } |
| 31 | |
| 32 | ### And she posts again |
| 33 | # @name second |
| 34 | POST {{base}}/posts |
| 35 | Authorization: Bearer {{alice.response.body.token}} |
| 36 | Content-Type: application/json |
| 37 | |
| 38 | { "body": "one sitting, one social network" } |
| 39 | |
| 40 | ### A post without a token |
| 41 | # @name anonymous |
| 42 | POST {{base}}/posts |
| 43 | Content-Type: application/json |
| 44 | |
| 45 | { "body": "who am I?" } |
| 46 | |
| 47 | ### Alice's posts, newest first |
| 48 | # @name list |
| 49 | GET {{base}}/users/alice/posts |
| 50 | |
| 51 | ### A third user |
| 52 | # @name carol |
| 53 | POST {{base}}/users |
| 54 | Content-Type: application/json |
| 55 | |
| 56 | { "handle": "carol" } |
| 57 | |
| 58 | ### Carol follows alice |
| 59 | # @name follow |
| 60 | POST {{base}}/users/alice/follow |
| 61 | Authorization: Bearer {{carol.response.body.token}} |
| 62 | |
| 63 | ### And she follows bob |
| 64 | # @name followBob |
| 65 | POST {{base}}/users/bob/follow |
| 66 | Authorization: Bearer {{carol.response.body.token}} |
| 67 | |
| 68 | ### Nobody by that name |
| 69 | # @name nobody |
| 70 | POST {{base}}/users/dave/follow |
| 71 | Authorization: Bearer {{carol.response.body.token}} |
| 72 | |
| 73 | ### Carol unfollows bob |
| 74 | # @name unfollow |
| 75 | DELETE {{base}}/users/bob/follow |
| 76 | Authorization: Bearer {{carol.response.body.token}} |
| 77 | |
| 78 | ### Carol follows herself |
| 79 | # @name herself |
| 80 | POST {{base}}/users/carol/follow |
| 81 | Authorization: Bearer {{carol.response.body.token}} |
| 82 | |
| 83 | ### Bob posts |
| 84 | # @name third |
| 85 | POST {{base}}/posts |
| 86 | Authorization: Bearer {{bob.response.body.token}} |
| 87 | Content-Type: application/json |
| 88 | |
| 89 | { "body": "bob here, good morning" } |
| 90 | |
| 91 | ### Alice posts once more |
| 92 | # @name fourth |
| 93 | POST {{base}}/posts |
| 94 | Authorization: Bearer {{alice.response.body.token}} |
| 95 | Content-Type: application/json |
| 96 | |
| 97 | { "body": "somebody is listening now" } |
| 98 | |
| 99 | ### Bob posts while carol is reading |
| 100 | # @name late |
| 101 | POST {{base}}/posts |
| 102 | Authorization: Bearer {{bob.response.body.token}} |
| 103 | Content-Type: application/json |
| 104 | |
| 105 | { "body": "while you were reading" } |
| 106 | |
| 107 | ### Carol's home feed, page one |
| 108 | # @name page1 |
| 109 | GET {{base}}/feed?limit=2 |
| 110 | Authorization: Bearer {{carol.response.body.token}} |
| 111 | |
| 112 | ### Page two |
| 113 | # @name page2 |
| 114 | GET {{base}}/feed?limit=2&cursor={{page1.response.body.next_cursor}} |
| 115 | Authorization: Bearer {{carol.response.body.token}} |
| 116 | |
| 117 | ### Page three |
| 118 | # @name page3 |
| 119 | GET {{base}}/feed?limit=2&cursor={{page2.response.body.next_cursor}} |
| 120 | Authorization: Bearer {{carol.response.body.token}} |
| 121 | |
| 122 | ### A cursor that isn't a post id |
| 123 | # @name badCursor |
| 124 | GET {{base}}/feed?cursor=latest |
| 125 | Authorization: Bearer {{carol.response.body.token}} |
| 126 | |
| 127 | ### A seeded user's feed (after make seed) |
| 128 | # @name seeded |
| 129 | GET {{base}}/feed?limit=2 |
| 130 | Authorization: Bearer seed-token-42 |
| 131 | |
| 132 | ### A quiet account posts (it has 30 followers) |
| 133 | # @name quietPost |
| 134 | POST {{base}}/posts |
| 135 | Authorization: Bearer seed-token-16726 |
| 136 | Content-Type: application/json |
| 137 | |
| 138 | { "body": "good morning from a quiet account" } |
| 139 | |
| 140 | ### One of its followers reads their feed |
| 141 | # @name follower |
| 142 | GET {{base}}/feed?limit=2 |
| 143 | Authorization: Bearer seed-token-2000 |
| 144 | |
| 145 | ### A reader who follows 199 accounts |
| 146 | # @name heavy |
| 147 | GET {{base}}/feed?limit=2 |
| 148 | Authorization: Bearer seed-token-363 |
| 149 | |
| 150 | ### The biggest account posts (it has 29,620 followers) |
| 151 | # @name bigPost |
| 152 | POST {{base}}/posts |
| 153 | Authorization: Bearer seed-token-1 |
| 154 | Content-Type: application/json |
| 155 | |
| 156 | { "body": "hello, everybody" } |
| 157 | |
| 158 | ### The biggest account posts again |
| 159 | # @name bigAgain |
| 160 | POST {{base}}/posts |
| 161 | Authorization: Bearer seed-token-1 |
| 162 | Content-Type: application/json |
| 163 | |
| 164 | { "body": "can anybody hear me?" } |
| 165 | |
| 166 | ### A follower of the biggest account reads their feed |
| 167 | # @name fan |
| 168 | GET {{base}}/feed?limit=2 |
| 169 | Authorization: Bearer seed-token-739 |
| 170 | |
| 171 | ### A quiet account posts while Redis refuses to write |
| 172 | # @name lost |
| 173 | POST {{base}}/posts |
| 174 | Authorization: Bearer seed-token-16726 |
| 175 | Content-Type: application/json |
| 176 | |
| 177 | { "body": "is this thing on?" } |
| 178 | |
| 179 | ### It posts again, and no worker is running |
| 180 | # @name queued |
| 181 | POST {{base}}/posts |
| 182 | Authorization: Bearer seed-token-16726 |
| 183 | Content-Type: application/json |
| 184 | |
| 185 | { "body": "this one waits for a worker" } |
| 186 | |
| 187 | ### And again, with Redis full and a worker running |
| 188 | # @name retried |
| 189 | POST {{base}}/posts |
| 190 | Authorization: Bearer seed-token-16726 |
| 191 | Content-Type: application/json |
| 192 | |
| 193 | { "body": "Redis was full when I wrote this" } |
| 194 | |
| 195 | ### One reader, again and again: watch RateLimit count down |
| 196 | # @name again |
| 197 | GET {{base}}/feed?limit=1 |
| 198 | Authorization: Bearer seed-token-42 |
| 199 | |
| 200 | ### The account that hammered us asks for its feed |
| 201 | # @name hammered |
| 202 | GET {{base}}/feed?limit=1 |
| 203 | Authorization: Bearer seed-token-16726 |
| 204 | |
| 205 | ### A reader asks for an empty page: all we want is the headers |
| 206 | # @name counted |
| 207 | GET {{base}}/feed?limit=1&cursor=1 |
| 208 | Authorization: Bearer seed-token-42 |
| 209 | |
| 210 | ### Somebody posts, while we take Redis away |
| 211 | # @name spare |
| 212 | POST {{base}}/posts |
| 213 | Authorization: Bearer seed-token-2000 |
| 214 | Content-Type: application/json |
| 215 | |
| 216 | { "body": "is Redis there?" } |
| 217 | |
| 218 | ### Somebody likes the quiet account's post |
| 219 | # @name like |
| 220 | POST {{base}}/posts/{{quietPost.response.body.id}}/like |
| 221 | Authorization: Bearer seed-token-2000 |
| 222 | |
| 223 | ### And takes the like back |
| 224 | # @name unlike |
| 225 | DELETE {{base}}/posts/{{quietPost.response.body.id}}/like |
| 226 | Authorization: Bearer seed-token-2000 |
| 227 | |
| 228 | ### A like for a post that doesn't exist |
| 229 | # @name missing |
| 230 | POST {{base}}/posts/999999999/like |
| 231 | Authorization: Bearer seed-token-2000 |
| 232 | |
| 233 | ### The top of that user's feed |
| 234 | # @name liked |
| 235 | GET {{base}}/feed?limit=1 |
| 236 | Authorization: Bearer seed-token-2000 |
| 237 | |
| 238 | ### A follower of the biggest account reads the top of their feed |
| 239 | # @name reader |
| 240 | GET {{base}}/feed?limit=1 |
| 241 | Authorization: Bearer seed-token-739 |
| 242 | |
| 243 | ### The quiet account's notifications, newest first |
| 244 | # @name inbox |
| 245 | GET {{base}}/notifications?limit=2 |
| 246 | Authorization: Bearer seed-token-16726 |
| 247 | |
| 248 | ### How many of them it hasn't seen |
| 249 | # @name unread |
| 250 | GET {{base}}/notifications/unread |
| 251 | Authorization: Bearer seed-token-16726 |
| 252 | |
| 253 | ### It has seen everything up to the newest one |
| 254 | # @name seen |
| 255 | POST {{base}}/notifications/read |
| 256 | Authorization: Bearer seed-token-16726 |
| 257 | Content-Type: application/json |
| 258 | |
| 259 | { "up_to": {{inbox.response.body.notifications[0].id}} } |
| 260 | |
| 261 | ### The biggest account looks at its bell |
| 262 | # @name bigUnread |
| 263 | GET {{base}}/notifications/unread |
| 264 | Authorization: Bearer seed-token-1 |
| 265 | |
| 266 | ### And at its list |
| 267 | # @name bigInbox |
| 268 | GET {{base}}/notifications?limit=1 |
| 269 | Authorization: Bearer seed-token-1 |
| 270 | |
| 271 | ### Three more people like the quiet account's post |
| 272 | # @name like2 |
| 273 | POST {{base}}/posts/{{quietPost.response.body.id}}/like |
| 274 | Authorization: Bearer seed-token-739 |
| 275 | |
| 276 | ### |
| 277 | # @name like3 |
| 278 | POST {{base}}/posts/{{quietPost.response.body.id}}/like |
| 279 | Authorization: Bearer seed-token-42 |
| 280 | |
| 281 | ### |
| 282 | # @name like4 |
| 283 | POST {{base}}/posts/{{quietPost.response.body.id}}/like |
| 284 | Authorization: Bearer seed-token-363 |
| 285 | |
| 286 | ### An account with 966 followers posts: the biggest fan-out we still push |
| 287 | # @name widePost |
| 288 | POST {{base}}/posts |
| 289 | Authorization: Bearer seed-token-115 |
| 290 | Content-Type: application/json |
| 291 | |
| 292 | { "body": "hello to all 966 of you" } |
| 293 | |
| 294 | ### Episode 16: the quiet account posts |
| 295 | # @name mine |
| 296 | POST {{base}}/posts |
| 297 | Authorization: Bearer seed-token-16726 |
| 298 | Content-Type: application/json |
| 299 | |
| 300 | { "body": "did this make it?" } |
| 301 | |
| 302 | ### and looks at its own page right away, as itself |
| 303 | # @name myPage |
| 304 | GET {{base}}/users/user16726/posts |
| 305 | Authorization: Bearer seed-token-16726 |
| 306 | |
| 307 | ### The same page, read by anybody else |
| 308 | # @name theirPage |
| 309 | GET {{base}}/users/user16726/posts |
| 310 | |
| 311 | ### Episode 17: somebody new signs up |
| 312 | # @name newcomer |
| 313 | POST {{base}}/users |
| 314 | Content-Type: application/json |
| 315 | |
| 316 | { "handle": "newcomer" } |
| 317 | |
| 318 | ### Whose token is this? |
| 319 | # @name whoAmI |
| 320 | GET {{base}}/me |
| 321 | Authorization: Bearer {{newcomer.response.body.token}} |
| 322 | |
| 323 | ### The newcomer's home feed |
| 324 | # @name newFeed |
| 325 | GET {{base}}/feed?limit=2 |
| 326 | Authorization: Bearer {{newcomer.response.body.token}} |
| 327 | |
| 328 | ### The biggest account's profile, as the newcomer sees it |
| 329 | # @name bigProfile |
| 330 | GET {{base}}/users/user1 |
| 331 | Authorization: Bearer {{newcomer.response.body.token}} |
| 332 | |
| 333 | ### A handle nobody has |
| 334 | # @name noSuchUser |
| 335 | GET {{base}}/users/nobody_here |
| 336 | |
| 337 | ### Who should the newcomer follow? |
| 338 | # @name whoToFollow |
| 339 | GET {{base}}/suggestions |
| 340 | Authorization: Bearer {{newcomer.response.body.token}} |
| 341 | |
| 342 | ### The newcomer follows the biggest account |
| 343 | # @name followBig |
| 344 | POST {{base}}/users/user1/follow |
| 345 | Authorization: Bearer {{newcomer.response.body.token}} |
| 346 | |
| 347 | ### Episode 18: the top of a reader's feed |
| 348 | # @name top |
| 349 | GET {{base}}/feed?limit=1 |
| 350 | Authorization: Bearer seed-token-2000 |
| 351 | |
| 352 | ### The reader likes that post |
| 353 | # @name likeTop |
| 354 | POST {{base}}/posts/{{top.response.body.posts[0].id}}/like |
| 355 | Authorization: Bearer seed-token-2000 |
| 356 | |
| 357 | ### The biggest account's posts, as anybody sees them |
| 358 | # @name bigPosts |
| 359 | GET {{base}}/users/user1/posts |
| 360 | |
| 361 | ### Its first page, one post long, as the reader sees it |
| 362 | # @name bigPage1 |
| 363 | GET {{base}}/users/user1/posts?limit=1 |
| 364 | Authorization: Bearer seed-token-2000 |
| 365 | |
| 366 | ### And the next page |
| 367 | # @name bigPage2 |
| 368 | GET {{base}}/users/user1/posts?limit=1&cursor={{bigPage1.response.body.next_cursor}} |
| 369 | Authorization: Bearer seed-token-2000 |
| 370 | |
| 371 | ### The quiet account's newest post, as the reader sees it |
| 372 | # @name quietTop |
| 373 | GET {{base}}/users/user16726/posts?limit=1 |
| 374 | Authorization: Bearer seed-token-2000 |
| 375 | |
| 376 | ### The reader likes it |
| 377 | # @name likeQuiet |
| 378 | POST {{base}}/posts/{{quietTop.response.body.posts[0].id}}/like |
| 379 | Authorization: Bearer seed-token-2000 |
| 380 | |
| 381 | ### The quiet account hears about it |
| 382 | # @name told |
| 383 | GET {{base}}/notifications?limit=1 |
| 384 | Authorization: Bearer seed-token-16726 |