The high-performance, resilient Edge API Gateway & Caching Proxy for APILayer on Deno Deploy.
Architecture • Features • Endpoints • Quick Start • Deno Deploy • License
- 🚀 Single-Flight Request Deduplication: Prevents "Cache Stampede / Thundering Herd" problems
by coalescing simultaneous concurrent requests for the same resource into a single outbound
promise to APILayer (
x-glastor-single-flight: COALESCED). - ⏰ Proactive Deno.cron Pre-warming: Native background serverless cron job that pre-refreshes key currency pairs every 10 minutes, guaranteeing sub-millisecond edge cache hits without cold start latencies.
- ⚡ Quota Preservation & Deno KV Caching: Eliminates redundant calls and saves monthly APILayer tier limits by maintaining multi-tiered edge cache (L1 Memory + L2 Deno KV) with dynamic TTL.
- 🛡️ Stale-While-Revalidate Grace Fallback: If APILayer experiences downtime or quota
exhaustion, Medusa automatically serves cached stale responses (
x-glastor-cache: STALE) without throwing outages to end users. - 🔒 Autonomous Circuit Breaker: Fast-fails downstream requests when upstream error thresholds are exceeded, preventing cascade timeouts and server lockups.
- 🌐 Distributed Rate Limiting: Enforces sliding-window rate limiting per client IP or token using Deno KV atomic commits.
- 🔍 Core 4R Observability: Every error implements the Glastor Standard:
code,reason,recovery,remediation, and correlationrequestId. - 🧪 Live Glassmorphic Console: Beautiful dark-mode dashboard at
/for interactive edge testing, latency measurement, and health tracking. - 🚀 Multi-Runtime / Zero-Config: Native to Deno 2 and Deno Deploy with zero build step required.
| Method | Endpoint | Description | Default Cache TTL |
|---|---|---|---|
GET |
/ |
Live Edge Interactive Console & Dashboard (HTML or JSON) | Real-time |
GET |
/health |
Gateway health status, circuit breakers, and telemetry | Real-time |
GET |
/openapi.json |
OpenAPI 3.1 self-describing contract | Static |
GET |
/v1/currency/convert |
Currency conversion (?from=USD&to=EUR&amount=100) |
10 minutes |
GET |
/v1/currency/latest |
Latest exchange rates (?base=USD&symbols=EUR,GBP) |
15 minutes |
GET |
/v1/ip-geo/lookup |
IP Geolocation (?ip=8.8.8.8 or auto-detect from client) |
24 hours |
GET |
/v1/email-verify/check |
Email deliverability & MX check (?email=user@domain.com) |
1 hour |
ALL |
/v1/proxy/* |
Universal resilient proxy to any APILayer endpoint | Configurable |
- Deno 2.x installed.
- APILayer API Key from apilayer.com.
-
Clone & Configure Environment:
cp .env.example .env # Edit .env and insert your APILAYER_API_KEY -
Run Dev Server with Watch Mode:
deno task dev
-
Open Edge Console: Visit http://localhost:8000 to access the live glassmorphic edge console.
-
Run Quality Suite & Tests:
deno task check # Type checking deno task lint # Code linting deno task test # Unit & integration tests deno task fmt # Code formatting
- Push this repository to your GitHub organization (
glastor-core/medusa). - Log in to Deno Deploy Console and create a New Project.
- Link your GitHub repository and set the entrypoint to:
src/server.ts - In Project Settings > Environment Variables, add:
APILAYER_API_KEY:your_apilayer_access_keyMEDUSA_API_KEY:your_private_gateway_token(Required in production for perimeter authentication)CORS_ALLOWED_ORIGINS: (Optional: comma-separated list of allowed origins, defaults to*in dev)
Use the included deploy.yml workflow:
- Configure GitHub repository secret
DENO_DEPLOY_TOKEN(from Deno Deploy Access Tokens). - Every push to
mainautomatically runs checks, tests, and deploys globally viajsr:@deno/deployctl.
Licensed under the Apache License 2.0. See LICENSE for details.