Skip to content

chore: Don't require envs in build time, and load them dynamically#11

Merged
patrick11514 merged 1 commit intomainfrom
fix/use-dynamic-env
Jan 29, 2026
Merged

chore: Don't require envs in build time, and load them dynamically#11
patrick11514 merged 1 commit intomainfrom
fix/use-dynamic-env

Conversation

@patrick11514
Copy link
Owner

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors environment variable management by moving from SvelteKit's static environment imports ($env/static/private) to dynamic imports ($env/dynamic/private) with centralized validation using Zod. This change allows environment variables to be loaded at runtime rather than at build time, making the application more flexible for different deployment environments.

Changes:

  • Created a new centralized env.ts module with Zod schema validation for all environment variables
  • Migrated all files using $env/static/private to import from the new env module
  • Removed parseInt calls where Zod's z.coerce.number() now handles string-to-number conversion

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/server/env.ts New file that defines and validates environment variables using Zod schema, providing type-safe access to configuration
src/lib/server/variables.ts Updated to use the new centralized env module instead of static env imports
src/lib/server/nina.ts Removed default fallback logic as defaults are now handled by Zod schema
src/lib/server/functions.ts Updated to import FILE_FOLDER from the new env module
src/routes/image/[name]/+server.ts Updated to import FILE_FOLDER from the new env module and reorganized imports
src/lib/server/_routes/upload.ts Updated to import FILE_FOLDER from the new env module and reorganized imports
src/lib/server/_routes/login.ts Updated to import COOKIE_EXPIRE from the new env module
src/lib/server/_routes/article.ts Updated to import FILE_FOLDER from the new env module
src/lib/server/_routes/ai.ts Updated to import GEMINI_API_KEY from the new env module

@patrick11514 patrick11514 merged commit 2405670 into main Jan 29, 2026
9 checks passed
@patrick11514 patrick11514 deleted the fix/use-dynamic-env branch January 29, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant