Validate your environment variables with Zod! process.env by default does not automatically pick up the environment variables that you define. It also can't validate if all the required variables are set, so you'll get an error during runtime if they're not. We can fix that by using Zod to create a schema of our env variables and validate process.env against it. Exporting the schema will also provide us with the correct types, so we won't mistype an environment variable ever again.
🔗 Links:
👉 Zod: zod.dev/
👉 Read the article: creatures.sh/blog/env-type-safety-and-validation/
--
🤝 Become a friend of the channel! Start your membership today and get extra benefits: youtube.com/channel/UCTexaJMnN_Pv6TVueQ61-oQ/join
💬 A bunch of us are hanging out at discord.creatures.sh/. Join us!
🐦 Find me on the bird app: twitter.com/NikolovLazar
🎥 What I use for coding and making videos: nikolovlazar.com/uses
コメント