Add Trocador webhook receiver, trade-status cache, and sparkline history

- POST /v1/trocador-webhook: Trocador hits this on every trade status change;
  stored in KV under trade:<id> for 14 days (matching Trocador's retention).
- GET /v1/trade/🆔 returns the cached trade body so the wallet can poll us
  instead of Trocador, dramatically reducing load on their infra per their
  commercial team's request.
- GET /v1/sparkline?coin=BTC&hours=24: returns hourly history points for
  rendering balance sparklines. Cron appends one entry per UTC hour per coin,
  capped at 168 points (1 week).
This commit is contained in:
jwinterm
2026-05-14 15:57:17 -04:00
parent 8f374a6470
commit 4f7c515808
4 changed files with 1684 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ workers_dev = true
# (The script also works without KV — it falls back to fetching upstream on each request.)
[[kv_namespaces]]
binding = "PRICES"
id = "REPLACE_ME_WITH_KV_NAMESPACE_ID"
id = "ccd6f69c03f14d9b8317eeaed2bf9f23"
# Run the refresh every 60 seconds.
# Cloudflare cron triggers fire once per minute at minimum.