Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TechDebt: API: Environment Variables Validation #1425

Merged
merged 11 commits into from
Nov 14, 2024
Merged

TechDebt: API: Environment Variables Validation #1425

merged 11 commits into from
Nov 14, 2024

Conversation

MacQSL
Copy link
Collaborator

@MacQSL MacQSL commented Nov 12, 2024

Description of Changes

Note: In my previous version env-config.ts exported a getter and setter for ENV values. I think the added complexity made it not worthwhile.
Now you get and set process.env values the regular way with the addition of process.env being fully typed. The app will crash on start up if the environment variables are not set correctly, still undecided if the loadEnvironmentVariables function should always exit the process, or only for development environments instead.

  • Validates environment variables against a zod schema
  • Extends the process.env type to include the inferred zod type
  • Updates some existing casting and default values

Testing Notes

  • App should work normally (when all environment variables exist in .env)
  • Need to validate that all the values in the schema are actually required. Should any be set to optional?

@MacQSL MacQSL changed the title TechDebt: Environment Variables Validation TechDebt: API: Environment Variables Validation Nov 12, 2024
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 21.05263% with 15 lines in your changes missing coverage. Please review.

Project coverage is 45.70%. Comparing base (462b432) to head (9d41a7d).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
api/src/utils/env-config.ts 0.00% 10 Missing ⚠️
api/src/app.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1425      +/-   ##
==========================================
- Coverage   45.72%   45.70%   -0.03%     
==========================================
  Files         801      802       +1     
  Lines       21639    21650      +11     
  Branches     3253     3248       -5     
==========================================
  Hits         9895     9895              
- Misses      11155    11166      +11     
  Partials      589      589              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MacQSL MacQSL added the Ready For Review PR is ready for review label Nov 13, 2024
@NickPhura
Copy link
Collaborator

Looks great!

@MacQSL MacQSL marked this pull request as ready for review November 14, 2024 17:57
Copy link
Collaborator

@NickPhura NickPhura left a comment

Choose a reason for hiding this comment

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

🕊️

@MacQSL MacQSL merged commit 365ce92 into dev Nov 14, 2024
21 of 23 checks passed
@MacQSL MacQSL deleted the mdENV branch November 14, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants