A lightweight Pastebin-style web application that allows users to create text pastes and share them via a unique URL. Pastes can optionally expire based on time-to-live (TTL) and/or a maximum view count. Once any configured constraint is exceeded, the paste becomes unavailable.
This project was built to satisfy all functional, API, and robustness requirements defined in the take-home assignment and is designed to pass automated grading tests.
- Create a paste with arbitrary text content
- Generate a shareable URL for each paste
- View pastes via API or browser
- Optional constraints:
- Time-based expiry (TTL)
- View-count limit
- Deterministic time handling for automated tests
- Persistent storage suitable for serverless environments
- Clean error handling with consistent JSON responses
- Framework: Next.js (App Router)
- Language: TypeScript
- Persistence Layer: Redis (KV-style storage)
- Type Checks : Zod , React Hook form
- Deployment Target: Vercel (or equivalent serverless platform)
- Pastes are stored as JSON objects in Redis with metadata:
contentcreated_atexpires_at(optional)remaining_views(optional)
- TTL is enforced logically (not relying solely on Redis expiry) to support deterministic testing.
- Each successful fetch decrements
remaining_viewsatomically. - All unavailable states (missing, expired, view-exceeded) return HTTP
404.
GET /api/healthz
Returns the application health and verifies access to the persistence layer.
Response
{ "ok": true }POST /api/pastes
{
"content": "string",
"ttl_seconds": 60,
"max_views": 5
}{
"id": "string",
"url": "https://pastebin-clone.vercel.app/p/<id>"
}Redis is used as the persistence layer to ensure data survives across requests in a serverless environment.
- Reasons for Choosing Redis
- Low latency
- Simple key-value access pattern
- Suitable for ephemeral but persistent data
- Works reliably on Vercel and similar serverless platforms
- No in-memory-only storage is used for paste data.
- Node.js 18 or later
- Redis instance (local or remote)
git clone <repository-url>
cd pastebin-liteREDIS_URL=redis://localhost:6379
NEXT_PUBLIC_APP_URL=http://localhost:3000bun install
bun dev