Add Companies House API client with rate limiting, caching, and vitest

↗ view on GitHub · sloth-ninja · 2026-07-08 · 9bbc94db

New backend/src/lib/companiesHouse.ts: typed client for
api.company-information.service.gov.uk (HTTP Basic auth, company-number
normalisation, in-process token bucket + single-flight de-dupe from the
new generic backend/src/lib/rateLimit.ts, TTL cache, 401/404/429/5xx
error mapping). Errors never include the raw key.

Also stands up the vitest harness upstream never shipped
("vitest": "^3.2.4", vitest.config.ts, `npm test`), with 21 TDD unit
tests covering auth headers, normalisation, rate limiting (fake
timers), caching, single-flight, and error mapping.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Repository Sloth-ninja/JessicaOSS
Author sloth-ninja <ezanahaddis@gmail.com>
Authored
Committed
Parents 60169a4d
Stats 3 files changed , +631
Part of WS1: Companies House integration (UK company data)

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-9bbc94db.md from inside the repo you want the change in.

⬇ Download capture-commit-9bbc94db.md