Skip to content

[Frontend] Implement lib/env.ts #144

Description

@Muhammadcodes112

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

  • Reading a set env var returns its value
  • Reading NEXT_PUBLIC_API_BASE_URL when unset throws a clear, specific error message (not undefined silently flowing through)
  • npm run typecheck passes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendNext.js app (astre_frontend)good first issueGood for newcomersphase-1Core donation-loop MVP (1/3 scope), builds on mvp-phase-1 branch

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions