A production-grade UHRP host server backed by Google Cloud Storage. Stores large files in cloud buckets with optional billing/micropayments and includes advertising infrastructure for overlay network discovery.
A TypeScript/Express server designed for Google Cloud Run that implements UHRP workflows backed by Google Cloud Storage. Static object retrieval is public; upload, list, find, and renewal require BRC-103 identity. A separate administrative advertisement endpoint uses a strong Bearer token.
Clients upload files with authentication, retrieve files via public GET, and server continuously advertises hosting capability.
| Type | Requirement |
|---|---|
| Database | None; Google Cloud Storage is the object and metadata source of truth |
| External services | Google Cloud Storage bucket, ARC API key, Wallet Storage, Bugsnag (optional) |
| ts-stack packages | @bsv/sdk, @bsv/auth-express-middleware, @bsv/payment-express-middleware, @bsv/wallet-toolbox, @bsv/wallet-toolbox-client |
| Method | Path | Purpose |
|---|---|---|
| GET/HEAD | Static object paths | Retrieve stored objects (public) |
| POST | /advertise | Administrative advertisement using Authorization: Bearer |
| POST | /quote | Public storage-price quote |
| POST | /upload | Authenticated upload/payment workflow |
| GET | /list | List the authenticated uploader's objects |
| GET | /find | Find authenticated uploader metadata |
| POST | /renew | Authenticated ownership/payment renewal |
| GET | /health, /healthz | Public process liveness |
| GET | /ready | Public initialization readiness |
None; HTTP-only with background advertising worker.
| Variable | Required | Description |
|---|---|---|
| HTTP_PORT | No | Express server port (default: 8080, typically 8080 for Cloud Run) |
| NODE_ENV | No | development, staging, or production |
| SERVER_PRIVATE_KEY | Yes | 256-bit hex private key for server identity |
| HOSTING_DOMAIN | No | Public HTTPS domain for advertising (e.g., https://uhrp-storage.example.com) |
| BSV_NETWORK | No | Target blockchain network (main, test, or regtest) |
| WALLET_STORAGE_URL | No | Wallet storage endpoint (e.g., https://store-us-1.bsvb.tech) |
| PRICE_PER_GB_MO | No | Monthly storage price per GB for billing |
| ENABLE_PAYMENT_MIDDLEWARE | No | Set to 'true' to require payment for uploads |
| GOOGLE_CLOUD_PROJECT | No | GCP project ID (auto-detected from service account if available) |
| GOOGLE_CLOUD_BUCKET | Yes | Cloud Storage bucket name (e.g., uhrp-storage-prod) |
| GOOGLE_APPLICATION_CREDENTIALS | No | Path to service account JSON key (for local/Cloud Run auth) |
| ARC_API_KEY | No | ARC API key for transaction broadcasting (advertising) |
| ADVERTISE_INTERVAL_MS | No | Interval for re-advertising to overlay (default: 3600000ms = 1 hour) |
| BUGSNAG_API_KEY | No | Bugsnag error reporting API key (optional) |
| ADMIN_TOKEN | Yes | At least 32 random characters for /advertise Bearer auth |
| UHRP_CORS_MODE | No | public (default), allowlist, or disabled |
| UHRP_CORS_ALLOWED_ORIGINS | No | Exact comma-separated origins in allowlist mode |
| UHRP_CORS_ALLOWED_HEADERS | No | Strict comma-separated browser request-header allowlist; omit for additive compatibility |
| UHRP_JSON_MAX_BODY_BYTES | No | JSON body ceiling (default 262144) |
| TRUST_PROXY_HOPS | No | Exact trusted proxy hop count, 0 through 10 |
See Public Service Edge Security for full edge controls.
# Install dependencies
npm install
# Development with hot-reload
npm run dev
# Build TypeScript
npm run build
# Run production build
npm startRequires GCP service account credentials or emulator for local testing.
# Multi-stage build: pinned Node 24 alpine builder → production runtime
docker build -t uhrp-storage:latest .
# Deploy to Google Cloud Run
gcloud run deploy uhrp-storage \
--image uhrp-storage:latest \
--platform managed \
--region us-central1 \
--set-env-vars SERVER_PRIVATE_KEY=<hex-key>,GOOGLE_CLOUD_BUCKET=uhrp-storage-prod,ENABLE_PAYMENT_MIDDLEWARE=true
# Or deploy with docker-compose (local testing only)
docker compose up -dFollows GCP 12-factor patterns: stateless design, cloud bucket for file storage, Cloud SQL for optional metadata, Cloud Logging integration, Bugsnag for error tracking. Graceful shutdown via SIGTERM signal handling.
No database migrations. Google Cloud Storage is the durable source of truth.
GET /health and GET /healthz report process liveness.GET /ready returns 200 only after wallet-backed authentication and payment
middleware initialization completes; the container health check uses it.