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

Clarify internal usage of environment variables with an exported env variable #141

Closed
alan910127 opened this issue Nov 17, 2023 · 5 comments · Fixed by #142
Closed

Clarify internal usage of environment variables with an exported env variable #141

alan910127 opened this issue Nov 17, 2023 · 5 comments · Fixed by #142

Comments

@alan910127
Copy link
Contributor

Description

Currently, environment variables are used in several places in the project to determine the behavior.
However, it might be unclear for developers who are new to this codebase whether an environment variable is defined or not.
It should be helpful to have an exported env variable with the "actual" types for the variables or even with pre-validation.

Proposed Solution

We could either use:

  1. a separate module, or
  2. a validation library like zod

to validate the environment variables and export the object.

@JounQin
Copy link
Member

JounQin commented Nov 17, 2023

Isn't a simple export const envs = process.env as Env be fine enough?

@alan910127
Copy link
Contributor Author

I think there are some validations inside the logic right now (e.g. check for null), if we simply use type assertions, it might be pretty easy to forget to check them.

@JounQin
Copy link
Member

JounQin commented Nov 17, 2023

Only GITLAB_TOKEN env is required and well documented, I don't think that worth a validation.

@alan910127
Copy link
Contributor Author

If you think the type of environment variables is nice to have, I can go and implement it with option 1. 😄

@JounQin
Copy link
Member

JounQin commented Nov 17, 2023

Sure, thanks for doing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants