From 86c02e711148a6b29c840ea4ac42f609ef9aeb7d Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Fri, 29 May 2026 13:43:31 +0700 Subject: [PATCH] feat: implement type-safe environment configuration and add .env.example files for web and landing apps --- apps/landing/.env.example | 1 + apps/landing/src/environment/env.ts | 6 ++++++ apps/web/.env.example | 2 ++ apps/web/src/environment/env.ts | 10 ++++++++++ 4 files changed, 19 insertions(+) create mode 100644 apps/landing/.env.example create mode 100644 apps/landing/src/environment/env.ts create mode 100644 apps/web/.env.example create mode 100644 apps/web/src/environment/env.ts diff --git a/apps/landing/.env.example b/apps/landing/.env.example new file mode 100644 index 0000000..36c47e4 --- /dev/null +++ b/apps/landing/.env.example @@ -0,0 +1 @@ +VITE_CMS_API_URL=http://localhost:8001/cms diff --git a/apps/landing/src/environment/env.ts b/apps/landing/src/environment/env.ts new file mode 100644 index 0000000..b54810f --- /dev/null +++ b/apps/landing/src/environment/env.ts @@ -0,0 +1,6 @@ +/** + * Type-safe Environment Wrapper for apps/landing. + */ +export const ENV = { + CMS_API_URL: import.meta.env.VITE_CMS_API_URL || 'http://localhost:8001/cms', +} as const; diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..c0215e8 --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,2 @@ +VITE_API_BASE_URL=http://localhost:8000/api +VITE_APP_ENV=development diff --git a/apps/web/src/environment/env.ts b/apps/web/src/environment/env.ts new file mode 100644 index 0000000..0755a0a --- /dev/null +++ b/apps/web/src/environment/env.ts @@ -0,0 +1,10 @@ +/** + * Type-safe Environment Wrapper for apps/web. + * DO NOT use `import.meta.env` directly in components. Import this `ENV` object instead. + */ +export const ENV = { + API_BASE_URL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000/api', + APP_ENV: (import.meta.env.VITE_APP_ENV || 'development') as 'development' | 'staging' | 'production', + IS_PROD: import.meta.env.VITE_APP_ENV === 'production', +} as const; +