API Infrastructure

JSON API with Rate Limiting

A typed REST API with per-IP rate limiting, structured errors, and a health endpoint.

What You’ll Get

A professional REST API that other apps can talk to. It accepts and returns JSON data, limits how many requests each user can make (so nobody can abuse it), and returns clear error messages when something goes wrong. It includes a health check endpoint so monitoring tools can verify it’s running. You add your business logic on top of this tested foundation.

Tech Stack Explained

Every tool in this recipe, explained in plain English.

Hono — The web framework that handles routing — deciding which code runs when someone hits /api/users vs /api/products.
Cloudflare KV — A simple key-value database that tracks rate limits. It remembers how many requests each IP address has made. Sign up →
TypeScript — A version of JavaScript with type checking. It catches bugs before your code runs, like a spell-checker for programming.
Vitest — The testing tool that verifies your API works correctly. It runs hundreds of checks in seconds.

The QRALPH Prompt

Copy this prompt and paste it into Claude Code. This is exactly what you’d say to QRALPH to build this project.

/qralph:qralph Build me a typed JSON REST API with rate limiting. I need a Hono-based API deployed to Cloudflare Workers with per-IP rate limiting stored in Cloudflare KV (5 requests per minute). Include structured JSON error responses with proper HTTP status codes, a /health endpoint, and CORS headers for cross-origin requests. TypeScript with strict types. Full Vitest test coverage.

What Happens Next

QRALPH builds the API with middleware for rate limiting, CORS, and error handling already wired up. Every endpoint gets typed request and response interfaces. The test suite covers normal requests, rate limit exceeded scenarios, CORS preflight, and malformed input. You get a production-ready API skeleton — just add your routes.

← Back to All Recipes