Tags

HTTP

HTTP

0 lessons
1 system design
6 community items

http

Community

6 items
Code Snippet

Why I Stopped Mocking `fetch` and Reached for MSW

The two-handler MSW setup I drop into every Vitest project. Pattern-matched URL routing, typed JSON responses, and per-test overrides without re-importing the server.

TypeScript
testing
http
code-template
utility

1k

26

4.4 (9)

May 8, 2026

by @ezb1981

Code Snippet

The Fetch Wrapper I Keep in Every Project

My zero-dep `apiFetch` for Node and the browser. Adds a per-request timeout, retries with jittered backoff on 5xx and network failures, parses JSON, and attaches an auth token without leaking it into errors.

JavaScript
http
error-handling
code-template
utility

1k

32

4.2 (9)

Apr 13, 2026

by @leoeriksson

Code Snippet

A Server-Sent Events Consumer That Reconnects

The Node-friendly SSE client I write whenever the browser `EventSource` is the wrong tool. Parses the line protocol by hand, resumes from `Last-Event-ID`, and applies bounded backoff between retries.

JavaScript
sse
real-time
http
code-template

813

7

4.3 (12)

Mar 29, 2026

by @jordandubois

Article

Error Handling in REST APIs: The Shape I Settled On

RFC 7807 plus a code, requestId, errors array, and documentationUrl. The eight fields earning their keep, the status codes everyone confuses, and what changed my mind across four APIs.

error-handling
rest-api
api-design
http
backend

492

10

Jan 14, 2026

by @leoeriksson

Article

CDN 101: Edge Caches, Origin Shields, and Cache Keys

The cache key matters more than the TTL. Origin shield is a cheap config win. Most CDN incidents are key bugs, not capacity bugs.

cdn
caching
origin-shield
http
system-design

1.1k

18

Dec 10, 2025

by @nadiaali

Article

API Versioning Strategies Without the Pain

Pick a versioning strategy on the day you ship the first version. URI versioning is the safe default, calendar dating is the gold standard, and your first release IS a contract.

versioning
api-design
rest-api
backend
http

509

9

Nov 21, 2025

by @khalidcooper