A minimal web app that fetches U.S. National Weather Service forecasts (via api.weather.gov) for a provided location. The project demonstrates a small full-stack setup using a Vite + React frontend and a Cloudflare Worker backend. It includes a local SRH (Serverless Redis HTTP) option for Redis-backed caching and an option to use Upstash for remote Redis in production-like environments.
- Query NWS Weather.gov points API and display a three-day forecast.
- Server-side caching using Redis (local SRH or Upstash).
X-User-Emailheader propagation: client sends configured email on requests, Worker forwards it to upstreams (e.g., weather.gov).- Local development helper tasks (
task dev,task env-setup,task ensure-srh) to start required services and the dev server.
- Node.js (recommended LTS) and npm
- Docker Desktop (needed to run SRH locally)
- Task (Taskfile runner) — https://taskfile.dev/ (this repository includes
Taskfile.yml) - PowerShell (Windows) or a POSIX-compatible shell (macOS/Linux) for interactive setup scripts
Create .env.local (or run task env-setup to generate it). Important variables:
ENV_MODE:srh(local SRH) orupstash- SRH (local) variables:
SRH_MODE,SRH_TOKEN,SRH_CONNECTION_STRING,SRH_PORT - Upstash variables:
UPSTASH_REDIS_REST_URL,UPSTASH_REDIS_REST_TOKEN EMAIL: contact email used for requestsVITE_EMAIL: mirroredEMAILvalue exposed to the client (used to sendX-User-Email)
Note: Vite only exposes env variables to the client if they are prefixed with
VITE_(we mirrorVITE_EMAILautomatically when runningtask env-setup).
- Install dependencies
npm install- Create
.env.localinteractively
task env-setup- On Windows this runs
setup-env.ps1, on macOS/Linux it runssetup-env.sh. - Choose
ENV_MODE=srhfor local development and provide anEMAILwhen prompted (this setsVITE_EMAILtoo).
- Start development server (ensures SRH when
ENV_MODE=srh)
task dev- Open the app (default Vite host:
http://localhost:5173) and perform searches. The client sendsX-User-Emailand the worker forwards it to upstreams.
task env-setup— create/update.env.local(runs an OS-specific script)task ensure-srh— ensures the configured backend is ready (starts local SRH whenENV_MODE=srh)task dev— ensures SRH and runs the Vite dev servertask stop-srh— stops and removes the local SRH containertask logs-srh— follow SRH container logs
Run unit and integration tests using Vitest:
npm testBuild and deploy using the existing npm scripts. Worker and static build steps:
npm run build
npm run deploy- If SRH doesn't start, run
task logs-srhto inspect container output. - Ensure
EMAIL/VITE_EMAILis set (client will includeX-User-Email). - If using Upstash, confirm
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENare present in.env.local.