Design a paste service where a user submits text, receives a unique short link, and anyone with that link can read the paste until it expires.
Example 1
Input: POST /pastes with { text: "Meeting notes", expiresIn: "24h" }
Output: 201 Created with { id: "p8K2mQ4x", url: "https://paste.example/p8K2mQ4x", expiresAt: "..." }
The service stores the paste and returns a link that can be shared.
Example 2
Input: GET /p8K2mQ4x before its expiry time
Output: 200 OK with the original text
Anyone with the link can read the paste while it is still valid.
Example 3
Input: GET /p8K2mQ4x after its expiry time
Output: 410 Gone
The service must check expiry on reads, even if stale data remains in storage or cache.
Constraints
- Paste bodies can be large, so store content separately from searchable metadata.
- The configured default expiry is 30 days and the maximum expiry is 365 days.
- An expired paste must never be served, including from a cache or CDN.
- The configured maximum paste size is 512 KB.
THINK ABOUT IT
What should the system do, and what should it skip?