Description
A single typed place to read NEXT_PUBLIC_* environment variables, instead of scattering process.env.X (and its possible-undefined-ness) throughout the codebase.
Where
astre_frontend/lib/env.ts (new file)
What to implement
Export a typed object or set of functions for reading NEXT_PUBLIC_API_BASE_URL and NEXT_PUBLIC_STELLAR_NETWORK. For NEXT_PUBLIC_API_BASE_URL, throw a clear error at call time if it's unset (fail loud, not with a silent wrong default) — see lib/contract-service.ts's existing NEXT_PUBLIC_CONTRACT_ID check for the pattern to follow.
Acceptance Criteria
Description
A single typed place to read
NEXT_PUBLIC_*environment variables, instead of scatteringprocess.env.X(and its possible-undefined-ness) throughout the codebase.Where
astre_frontend/lib/env.ts(new file)What to implement
Export a typed object or set of functions for reading
NEXT_PUBLIC_API_BASE_URLandNEXT_PUBLIC_STELLAR_NETWORK. ForNEXT_PUBLIC_API_BASE_URL, throw a clear error at call time if it's unset (fail loud, not with a silent wrong default) — seelib/contract-service.ts's existingNEXT_PUBLIC_CONTRACT_IDcheck for the pattern to follow.Acceptance Criteria
NEXT_PUBLIC_API_BASE_URLwhen unset throws a clear, specific error message (notundefinedsilently flowing through)npm run typecheckpasses