From fc21cc90b0287c2ea98a7b6cae74b37367ffa4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Mon, 22 Apr 2024 17:35:23 +0000 Subject: [PATCH] AW-31-addEnvVariables --- environments/.env.develop | 6 ++++++ environments/.env.production | 6 ++++++ package.json | 6 +++++- src/env.d.ts | 8 ++++++++ src/routes.ts | 17 +++++++---------- vite.config.ts | 2 ++ 6 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 environments/.env.develop create mode 100644 environments/.env.production create mode 100644 src/env.d.ts diff --git a/environments/.env.develop b/environments/.env.develop new file mode 100644 index 0000000..1aaa843 --- /dev/null +++ b/environments/.env.develop @@ -0,0 +1,6 @@ +AURA_API_HOST=https://api-web.aura.wit.life +AURA_DAPI_HOST=https://dev.api.aura.witapps.us +AURA_SITE_HOST=https://aura.wit.life +AURA_PREFIX=api/v1 +AURA_OPEN_AI_HOST=https://api.openai.com +AURA_OPEN_AI_PREFIX=v1 \ No newline at end of file diff --git a/environments/.env.production b/environments/.env.production new file mode 100644 index 0000000..05cd7ea --- /dev/null +++ b/environments/.env.production @@ -0,0 +1,6 @@ +AURA_API_HOST=https://api-web.aura.wit.life +AURA_DAPI_HOST=https://api.aura.witapps.us +AURA_SITE_HOST=https://aura.wit.life +AURA_PREFIX=api/v1 +AURA_OPEN_AI_HOST=https://api.openai.com +AURA_OPEN_AI_PREFIX=v1 \ No newline at end of file diff --git a/package.json b/package.json index eedc075..965f5b4 100755 --- a/package.json +++ b/package.json @@ -7,7 +7,11 @@ "dev": "vite --host", "build": "tsc && vite build", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "start:dev": "vite --host --mode develop", + "start:prod": "vite --host --mode production", + "build:dev": "tsc && vite build --mode develop", + "build:prod": "tsc && vite build --mode production" }, "dependencies": { "@reduxjs/toolkit": "^1.9.5", diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..d15030a --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,8 @@ +interface ImportMetaEnv { + AURA_API_HOST: string, + AURA_DAPI_HOST: string, + AURA_SITE_HOST: string, + AURA_PREFIX: string, + AURA_OPEN_AI_HOST: number, + AURA_OPEN_AI_PREFIX: string +} \ No newline at end of file diff --git a/src/routes.ts b/src/routes.ts index 94f3ad3..574f62b 100755 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,17 +1,14 @@ import type { UserStatus } from "./types"; -const isProduction = import.meta.env.MODE === "production"; +const environments = import.meta.env const host = ""; -export const apiHost = "https://api-web.aura.wit.life"; -const dApiHost = isProduction - ? "https://api.aura.witapps.us" - : "https://dev.api.aura.witapps.us"; -// const dApiHost = "https://d.api.witapps.us"; -const siteHost = "https://aura.wit.life"; -const prefix = "api/v1"; -const openAIHost = " https://api.openai.com"; -const openAiPrefix = "v1"; +export const apiHost = environments.AURA_API_HOST; +const dApiHost = environments.AURA_DAPI_HOST +const siteHost = environments.AURA_SITE_HOST +const prefix = environments.AURA_PREFIX; +const openAIHost = environments.AURA_OPEN_AI_HOST; +const openAiPrefix = environments.AURA_OPEN_AI_PREFIX; const routes = { client: { diff --git a/vite.config.ts b/vite.config.ts index 09f8f7b..89b458a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,4 +19,6 @@ export default defineConfig({ path: '/hmr/', }, }, + envDir: "./environments", + envPrefix: "AURA_" })