Edge Crypto-Pricing Proxy on Cloudflare Workers
Overview
A lightweight edge proxy service that fronts the CoinGecko pricing API for a consumer app, deployed on Cloudflare Workers. It validates requested tokens, fetches live coin prices, and caches results in Workers KV to keep latency low and stay within upstream rate limits.
Why It Exists
Calling a public pricing API directly from clients leaks keys, hits rate limits, and adds latency. A thin edge proxy centralises the integration, adds a validation/whitelist layer, and serves cached responses globally close to users.
What We Built
A TypeScript Cloudflare Worker (src/server) with a coingecko.service for upstream calls, a tokenValidator to whitelist accepted tokens, a cache.service backed by a PRICING Workers KV namespace, and shared types. The project scaffolds from a Durable Objects / PartyServer chat template and uses Wrangler for typed config, observability, and deploys. The coinlist package supplies the token reference set.
Technologies & Approach
TypeScript on Cloudflare Workers with Workers KV for the price cache and Wrangler for deployment and type generation. The edge runtime gives global low-latency reads; KV provides cheap, TTL-style caching of upstream responses. PartyServer/PartySocket and React Router remain from the starter template.
Outcome / Impact
A working, deployable edge proxy that demonstrates secure third-party API mediation, token whitelisting, and edge caching, a reusable pattern for any client app that needs rate-limited crypto market data without exposing upstream credentials.
Capabilities Demonstrated
- Serverless edge APIs on Cloudflare Workers
- Caching upstream data in Workers KV to cut latency and cost
- Secure mediation of third-party crypto pricing APIs
- Input/token validation and whitelisting
- Wrangler-based typed config, observability, and deployment