Skip to content

Conversation

tomast1337
Copy link
Member

This pull request introduces improvements to the configuration and validation of environment variables within the application.

Previously, validation was performed by comparing the .env.development.example file with the currently set environment variables. Now, the validation process has been enhanced by leveraging the class-validator and class-transformer libraries for a more robust and scalable approach.

The key updates include the implementation of a new validation mechanism for environment variables, the removal of outdated validation logic in the AppModule, and the reorganization of imports for better maintainability.

Configuration and Validation Enhancements:

  • New EnvironmentVariables Class: Added a dedicated class to define validation rules for environment variables using class-validator and class-transformer. This ensures that all required variables are present and properly formatted.
    (File: server/src/config/EnvironmentVariables.ts)

  • validate Function: Introduced a function that uses the plainToInstance method to transform and validate the environment variables. This function throws an error if any required variables are missing or incorrectly formatted.
    (File: server/src/config/EnvironmentVariables.ts)

Codebase Simplification:

  • Removed Legacy Validation Logic: Eliminated redundant code in the AppModule constructor that manually validated environment variables. The new validation function now handles this process, streamlining the codebase.

@tomast1337 tomast1337 requested a review from Bentroen December 20, 2024 15:56
@Bentroen Bentroen merged commit 2742271 into develop Dec 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants