Skip to content

refactor(config): enforce strict runtime validation for environment variables #26

Description

@0dillon

Summary

Currently, our application consumes environment variables using loose type casting (e.g., process.env.SECRET as string). This is a massive operational risk. If a required variable is missing or malformed during deployment, the API might start up successfully but crash unexpectedly during runtime when that specific configuration is accessed.

We need to implement a 'fail-fast' architecture at startup. By migrating our configuration logic to a strict Zod schema, we can validate the presence, type, and format of every environment variable the moment the Node process initializes. If the environment is invalid, the process must terminate immediately with a detailed error log.

Acceptance Criteria

  • Define a comprehensive Zod schema for all configuration variables.
  • Implement initialization logic to parse and validate process.env on startup.
  • Remove all unsafe type assertions from the codebase.
  • Ensure the process exits with code 1 if validation fails.

Tech Stack

TypeScript (Node.js 24), Zod.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions