You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Including all variables
pros: drop in replacement
cons: people might not validate their env vars
Excluding all the variables
pros: people are forced to validate vars (which is a success pit we want them in)
cons: people are annoyed/confused that they have to add validation for each variable they want to use
Now - we include only user variables that the users defined validation for (using the envValidationSchema feature) on the env object which users can import from wasp/server and wasp/client. While this has the benefit that it forces the user to define validations for env vars they want exposed on the env object.
The downside is that adding new env vars in the .env.client or .env.server does make them available as new fields on the env object with type of string | undefined (as they normally appear on the process.env or import.meta.env).
Implementation
We extend the ensureEnvSchema with & { [key: string]: string | undefined } and passthrough():
Idea: detect which vars they have, but are not validated, and then print a warning about it: hey I see you have vars you haven't validated, if you don't do so, you can't access them via env object, how about you validate them?
Based on Discord:
Now - we include only user variables that the users defined validation for (using the
envValidationSchema
feature) on theenv
object which users can import fromwasp/server
andwasp/client
. While this has the benefit that it forces the user to define validations for env vars they want exposed on theenv
object.The downside is that adding new env vars in the
.env.client
or.env.server
does make them available as new fields on theenv
object with type ofstring | undefined
(as they normally appear on theprocess.env
orimport.meta.env
).Implementation
We extend the
ensureEnvSchema
with& { [key: string]: string | undefined }
andpassthrough()
:and this results in this type:
The text was updated successfully, but these errors were encountered: