add environment variable validation with Joi in opsce module#861
Merged
yusuftomilola merged 1 commit intoJun 1, 2026
Conversation
add environment variable validation with Joi in opsce module
|
@Habibah371 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
yusuftomilola
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add Environment Variable Validation with Joi in Opsce Module
Summary
This PR introduces centralized environment variable validation using Joi within
ConfigModule.forRoot()to ensure the application fails fast when required configuration is missing or invalid.Previously, the application could start successfully even when critical environment variables such as database credentials or JWT secrets were absent, potentially leading to insecure behavior, runtime failures, or misconfigured deployments. With this change, configuration is validated during startup and descriptive errors are provided when validation fails.
Changes Implemented
Joi-Based Environment Validation
ConfigModule.forRoot()Required Environment Variables
The following variables are now mandatory and validated on startup:
DATABASE_URLJWT_SECRETJWT_REFRESH_SECRETREDIS_HOSTREDIS_PORTPORTValidation includes:
Optional Variables with Safe Defaults
Added validation and default values for optional configuration:
THROTTLE_TTLTHROTTLE_LIMITUPLOAD_DIRDefaults are applied only when values are not explicitly provided.
Startup Failure Protection
Security Improvements
Validation Examples
Valid Configuration
Startup Failure Example
Configuration validation error: "JWT_SECRET" is requiredThe application exits immediately and refuses to start until the configuration is corrected.
Testing
Added tests covering:
Acceptance Criteria
Benefits
Closes [BE-32] Add environment variable validation with Joi in opsce module #757