Skip to content

[Security] Strict Environment Variable Structuring and Startup Validation #165

Description

@AlAfiz

Description: The application currently attempts to boot up even if essential operational environment variables (e.g., DATABASE_URL, STELLAR_RPC_URL, JWT_SECRET) are missing or incorrectly formatted, causing hard-to-debug runtime panics much later down the line.
Context / Motivation: Forcing a fast, descriptive crash during the boot sequence prevents unstable, partially configured server containers from executing in production environments.
Acceptance Criteria:

  • Implement an initialization environment validation script that executes immediately upon server launch (npm run start).
  • Define precise typing parameters for each expected variable (e.g., ensuring PORT is a valid number, DATABASE_URL matches a valid connection URI protocol).
  • Gracefully exit the Node process with an explicit error log if any critical configuration value is missing.
    Technical Pointers: Use a tool like envalid or build a clean Zod schema configuration object (process.env parsing script) that parses and exports a strictly frozen, safe configuration object for use throughout the system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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