@paul @pdenya I've encountered a similar use-case when loading environment variables, validating them and exposing the result to the rest of the application.

Here's how I go about doing it, using Zod for parsing and transforming, and crashing early with helpful messages if something isn't right.

github.com/SocialGouv/e2esdk/b

Though the resulting env object is exported/imported rather than passed as arguments, in Fastify I could expose it as a server property and use that as dependency injection.

0
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Replies