[ANN] rescript-envsafe - Makes sure you don't accidentally deploy apps with missing or invalid environment variables

I’ve just release rescript-envsafe@1.0.0. It validates access to environment variables and parses them to the right type. So we won’t accidentally deploy apps with missing or invalid environment variables. No need to struggle like in the post anymore: Strategy for accessing Node environment variables.

❌ Invalid environment variables:
    API_URL ("http//example.com/graphql"): Invalid url
💨 Missing environment variables:
    MY_VAR: Disallowed empty string
    PORT: Missing value

Heavily inspired by the great project envsafe, but designed with care for ReScript users:

  • Always strict - only access the variables you have defined
  • Built for node.js and the browser
  • Composable parsers with rescript-struct

Basic usage

%%private(let envSafe = EnvSafe.make())

let nodeEnv =
      S.literalVariant(String("production"), #production),
      S.literalVariant(String("development"), #development),
      S.literalVariant(String("test"), #test),
let port = envSafe->EnvSafe.get(~name="PORT", ~struct=S.int()->S.Int.port(), ~devFallback=3000, ())
let apiUrl =
let auth0ClientId = envSafe->EnvSafe.get(~name="AUTH0_CLIENT_ID", ~struct=S.string(), ())
let auth0Domain = envSafe->EnvSafe.get(~name="AUTH0_DOMAIN", ~struct=S.string(), ())