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
Creates `envSafe` to start working with environment variables. By default it uses `process.env` as a base for plucking the vars, but it can be overridden using the `env` argument.
|`name`|`string`| Name of the environment variable |
97
-
|`struct`|`S.t<'value>`| A struct created with **[rescript-struct](https://github.com/DZakh/rescript-struct)**. It's used for coercion and parsing. For bool structs coerces `"0", "1", "true", "false", "t", "f"` to boolean values. For int and float structs coerces string to number. |
98
-
|`devFallback`|`'value=?`| A fallback value to use only when `NODE_ENV` is not `production`. This is handy for env vars that are required for production environments, but optional for development and testing. If you need to set fallback value for all environments, you can use `S.defaulted` on struct. |
99
-
|`input`|`string=?`| As some environments don't allow you to dynamically read env vars, we can manually put it in as well. Example: `input=%raw("process.env.NEXT_PUBLIC_API_URL")`. |
100
-
|`allowEmpty`|`bool=false`| Default behavior is `false` which treats empty strings as the value is missing. if explicit empty strings are OK, pass in `true`. |
|`name`|`string`| Name of the environment variable |
97
+
|`struct`|`S.t<'value>`| A struct created with **[rescript-struct](https://github.com/DZakh/rescript-struct)**. It's used for coercion and parsing. For bool structs coerces `"0", "1", "true", "false", "t", "f"` to boolean values. For int and float structs coerces string to number. |
98
+
|`devFallback`|`'value=?`| A fallback value to use only when `NODE_ENV` is not `production`. This is handy for env vars that are required for production environments, but optional for development and testing. If you need to set fallback value for all environments, you can use `S.Option.getOr` on struct. |
99
+
|`input`|`string=?`| As some environments don't allow you to dynamically read env vars, we can manually put it in as well. Example: `input=%raw("process.env.NEXT_PUBLIC_API_URL")`. |
100
+
|`allowEmpty`|`bool=false`| Default behavior is `false` which treats empty strings as the value is missing. if explicit empty strings are OK, pass in `true`. |
101
101
102
102
### **`EnvSafe.close`**
103
103
104
-
`(EnvSafe.t, unit) => unit`
104
+
`(EnvSafe.t) => unit`
105
105
106
106
```rescript
107
-
envSafe->EnvSafe.close()
107
+
envSafe->EnvSafe.close
108
108
```
109
109
110
110
It makes a readable summary of your issues, `console.error`-log an error, `window.alert()` with information about the missing envrionment variable if you're in the browser, throws an error (will exit the process with a code 1 in node).
0 commit comments