From e813bf9dd3464cc0d2a2b242222355de2f30e1e8 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois <git@bhasher.com> Date: Wed, 12 Feb 2025 13:04:33 +0100 Subject: [PATCH] Add default env for frontend --- frontend/.gitignore | 2 -- frontend/src/lib/config.ts | 15 +++++---------- frontend/src/types.d.ts | 9 ++++----- frontend/tsconfig.json | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/frontend/.gitignore b/frontend/.gitignore index 6635cf55..e91699ff 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -3,8 +3,6 @@ node_modules /build /.svelte-kit /package -.env -.env.* !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* diff --git a/frontend/src/lib/config.ts b/frontend/src/lib/config.ts index 3d0e49fd..22c87bb5 100644 --- a/frontend/src/lib/config.ts +++ b/frontend/src/lib/config.ts @@ -1,15 +1,10 @@ -import { - PUBLIC_API_URL, - PUBLIC_API_PROXY, - PUBLIC_APP_URL, - PUBLIC_WS_URL -} from '$env/static/public'; +import { env } from '$env/dynamic/public'; export default { - API_URL: PUBLIC_API_URL || 'https://languagelab.be/tmp-api', - API_PROXY: PUBLIC_API_PROXY || 'https://languagelab.be/tmp-api', - APP_URL: PUBLIC_APP_URL || 'https://languagelab.be', - WS_URL: PUBLIC_WS_URL || 'wss://languagelab.be/tmp-api/v1/ws', + API_URL: env.PUBLIC_API_URL, + API_PROXY: env.PUBLIC_API_PROXY, + APP_URL: env.PUBLIC_APP_URL, + WS_URL: env.PUBLIC_WS_URL, // 1 week - 2 hours WEEKLY_SURVEY_INTERVAL: (7 * 24 - 2) * 60 * 60 * 1000, LEARNING_LANGUAGES: { diff --git a/frontend/src/types.d.ts b/frontend/src/types.d.ts index 970eb1bd..b7f377b1 100644 --- a/frontend/src/types.d.ts +++ b/frontend/src/types.d.ts @@ -1,6 +1,5 @@ -declare module '$env/static/public' { - export const PUBLIC_API_URL: string; - export const PUBLIC_API_PROXY: string; - export const PUBLIC_APP_URL: string; - export const PUBLIC_WS_URL: string; +declare module '$env/dynamic/public' { + export const env: { + [key: string]: string; + }; } diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index a9380f39..a76f2ab5 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -15,6 +15,6 @@ "module": "ESNext", "isolatedModules": true }, - "include": ["src/**/*", "global.d.ts", ".svelte-kit/ambient.d.ts"], + "include": ["src/**/*", "global.d.ts"], "exclude": ["node_modules", ".svelte-kit/*", "build/*"] } -- GitLab