Lookup Node.js environment variables.
Installing
spago install environment
Usage
Variables
lookup ∷ ∀ 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)
Environment
data Environment = Development | Production
detect ∷ ∀ 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
Documentation and more detailed examples are hosted on Pursuit.
Tooling
Dependencies
To install dependencies:
yarn install yarn spago install
Tests
To run tests:
yarn spago testDocumentation
To generate the documentation locally:
yarn spago docs
Linters
To run linters:
yarn lint
Formatters
To run formatters:
yarn format
Contributing
Please 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
Contributors
- Joel Lefkowitz - Initial work
Remarks
Lots of love to the open source community!