@wheen/store
v0.1.1
Published
Wheen library store — StorageAdapter + ObjectStore. R2 and HF buckets plug the same well.
Readme
@wheen/store
One library store. Cloudflare R2 and Hugging Face buckets both plug the same contract.
Browser ──HttpStorageAdapter──► Well Worker ──ObjectStore──► R2 or HF
App Local (IDB) ─────────────────────────────────────────────► (offline default)Contracts
| Surface | Role |
|---------|------|
| StorageAdapter | app persist (JSON + bytes) |
| ObjectStore | server backend (R2 / HF / memory) |
| createWellHandler | REST: /kv/* /bytes/* /health |
Backends (compatible)
| Kind | Free egress story | Setup |
|------|-------------------|--------|
| r2 (default ship) | Cloudflare R2 free egress | workers/wheen-well + wrangler |
| hf | HF Storage Buckets · CDN in plan | HF_TOKEN + HF_BUCKET |
| memory | tests | — |
Same well URL either way. App only needs VITE_WHEEN_WELL_URL.
App
import { HttpStorageAdapter, setStorage } from '@/lib/storage'
// if VITE_WHEEN_WELL_URL set → HttpStorageAdapter(well)Worker
cd workers/wheen-well
# R2 (pick this for game assets / free egress):
npx wrangler r2 bucket create wheen-store
npx wrangler dev
# or HF:
# STORE_BACKEND=hf HF_TOKEN=… HF_BUCKET=you/wheen-store npx wrangler devProtocol
GET|PUT|DELETE {well}/kv/{key}
GET|PUT|DELETE {well}/bytes/{key}
GET {well}/health → { ok, backend, protocol: "wheen-well/1" }