Skip to content

Validate access API environment configuration at startup #19

@Lakes41

Description

@Lakes41

Summary

Add strict environment configuration validation so the access API fails fast when required runtime settings are missing or malformed.

Current Behaviour

The API reads environment variables such as database settings, port values, Redis settings, chain configuration, and contract addresses across the application. Invalid or missing values can surface later as unclear runtime errors.

Expected Behaviour

Startup should validate all required configuration once, provide clear error messages, and prevent the server from booting with unsafe or incomplete settings.

Suggested Implementation

Create a central config module that parses process.env, validates required values, applies safe defaults, and exports a typed config object. Use this config throughout the API instead of reading environment variables directly.

Files or Areas Likely Affected

  • apps/access-api/src/config.ts
  • apps/access-api/src/index.ts
  • apps/access-api/src/services/prisma.ts
  • .env.example
  • README.md

Acceptance Criteria

  • Required environment variables are validated at startup
  • Invalid URLs, ports, chain IDs, and contract addresses produce clear errors
  • Application code uses a typed config object instead of direct process.env access
  • .env.example documents every required and optional setting
  • Tests cover valid config, missing values, and malformed values

Additional Notes

Assumption: the access API should fail closed when configuration is invalid rather than starting in a partially working state.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions