Lookup Node.js environment variables.
spago install environmentlookup ∷ ∀ m. MonadEffect m ⇒ String → String → m String
Look up an environment variable with a fallback:
import Node.Process.Environment (lookup)
lookup "BASE_URL" "/"require ∷ ∀ m. MonadEffect m ⇒ String → m String
Look up an environment variable, producing an Effect.Exception if it's missing:
import Node.Process.Environment (require)
require "BASE_URL"file:///Effect.Exception/foreign.js:6
return new Error(msg);
^
Error: Missing environment variable: BASE_URL
at Module.error (file:///Effect.Exception/foreign.js:6:10)Alternatively, if you want to return Nothing rather than a fallback or an error then Node.Process provides lookupEnv.
lookupEnv :: String → Effect (Maybe String)
data Environment = Development | Productiondetect ∷ ∀ m. MonadEffect m ⇒ m Environment
Lookup and parse the value of the NODE_ENV
import Prelude
import Effect (Effect)
import Node.Process.Environment (Environment(..))
import Node.Process.Environment as Environment
main ∷ Effect Unit
main = do
environment ← Environment.detect
case environment of
Production → ...
Development → ...Documentation and more detailed examples are hosted on Pursuit.
To install dependencies:
yarn install
yarn spago installTo run tests:
yarn spago testTo generate the documentation locally:
yarn spago docsTo run linters:
yarn lintTo run formatters:
yarn formatPlease read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.
This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.
Bump2version is used to version and tag changes. For example:
bump2version patch- Joel Lefkowitz - Initial work
Lots of love to the open source community!