You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* initial zod config utility
* Refactor configuration handling: remove ConfigContext and related hooks, update environment variable timestamps to UTC format
* Update testing guidelines: specify test file placement in __tests__ directory
* Add config schema validation tests using Zod
* Enhance configuration access by introducing a type-safe `config` utility with Zod validation for environment variables
Copy file name to clipboardExpand all lines: docs/CONFIGURATION_GUIDE.md
+35-16Lines changed: 35 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ The following environment variables are available for configuring the React appl
42
42
```env
43
43
VITE_BUILD_DATE=2026-02-10
44
44
VITE_BUILD_TIME=14:30:00
45
-
VITE_BUILD_TS=2026-02-10T14:30:00+0000
45
+
VITE_BUILD_TS=2026-02-10T14:30:00Z
46
46
VITE_BUILD_COMMIT_SHA=abc123def456
47
47
VITE_BUILD_ENV_CODE=dev
48
48
VITE_BUILD_WORKFLOW_NAME=Build
@@ -52,20 +52,35 @@ The following environment variables are available for configuring the React appl
52
52
53
53
### Accessing Configuration
54
54
55
-
Application configuration values are accessible directly in your React components since Vite automatically injects them:
55
+
Application configuration values are accessed through the `config` utility, which provides type-safe, validated configuration throughout your React components and utilities. The utility validates all environment variables at runtime using Zod schema validation, ensuring type safety and early error detection.
56
+
57
+
Import the `config` object from the common utilities:
-**Type Safety**: All configuration values are validated against a Zod schema, ensuring correct types
77
+
-**Validation**: Environment variables are validated on application startup, catching missing or invalid configuration early
78
+
-**IDE Support**: Full TypeScript autocomplete and type checking for configuration values
79
+
-**Single Source of Truth**: Configuration is centralized and consistently accessed throughout the application
80
+
81
+
**Configuration Schema Location:**
82
+
The Zod schema that validates all environment variables is defined in [src/common/utils/config.ts](../src/common/utils/config.ts). This file also exports the `Config` type for use in type annotations when needed.
83
+
69
84
### Local Development
70
85
71
86
For local development, create a `.env` file in the root directory with local values:
@@ -99,7 +114,7 @@ For running unit tests, create a `.env.test.local` file in the root directory wi
99
114
# Provided by Pipeline (Simulated)
100
115
VITE_BUILD_DATE=1970-01-01
101
116
VITE_BUILD_TIME=00:00:00
102
-
VITE_BUILD_TS=1970-01-01T00:00:00+0000
117
+
VITE_BUILD_TS=1970-01-01T00:00:00Z
103
118
VITE_BUILD_COMMIT_SHA=test
104
119
VITE_BUILD_ENV_CODE=test
105
120
VITE_BUILD_WORKFLOW_NAME=test
@@ -432,15 +447,19 @@ Ensure all required configuration variables are set as the correct type.
432
447
2. Ensure AWS CLI is configured with `aws configure`
433
448
3. Verify with: `aws sts get-caller-identity`
434
449
435
-
### Application Build Variables Not Available
450
+
### Application Configuration Validation Error
436
451
437
-
**Problem**: `import.meta.env.VITE_*` variables are undefined at runtime.
452
+
**Problem**: Application fails to start with a configuration validation error message.
438
453
439
454
**Solution**:
440
455
441
-
1. Ensure variables in `.env` are prefixed with `VITE_`
442
-
2. Restart the development server after changing `.env`
443
-
3. Verify with: `echo $VITE_BASE_URL_API`
456
+
1. Ensure all required variables in `.env` are present (see Environment Variables table above)
457
+
2. Ensure variables are prefixed with `VITE_` for Vite compatibility
458
+
3. Restart the development server after changing `.env`
459
+
4. Verify variables are set: `echo $VITE_BASE_URL_API`
460
+
5. The config utility will provide detailed error messages indicating which variables are missing or invalid
461
+
462
+
**Note**: The application uses the `config` utility from `common/utils/config` which validates all environment variables at startup using Zod schema validation. If any required variables are missing or have invalid values, the application will fail with a clear error message indicating the issue.
0 commit comments