- env-universal
- readEnv
- envDef
- env-universal/constants
- production
- test
- ci
- development
- qa
- staging
- preprod
- env-universal/utils
- getAppVersion
- getEnv
- getStage
- isDev
- isDeployed
- isCI
- isTest
- isQA
- isStaging
- isPreProd
- isProduction
- isHerokuReviewApp
- isServer
- isClient
- getPublicEnv
- getHerokuMetadata
- env-universal/serverUtils
- serverHost
- serverPort
Environment definitions and helpers
Note: in browser runtimes process.env
will need to be defined
via something like Webpack's DefinePlugin
Given an environment config (defaults to process.env
),
parse it into a standard environment definition
Parameters
config
Object (optional, defaultprocess.env
)
Returns Object envDef
A standardized environment description
- see
env-universal/constants
- see
env-universal/utils
Properties
mode
Stringprocess.env.NODE_ENV
stage
Stringprocess.env.APP_ENV
version
String NPM package versionis
Object config flags based on envserver
Object server env configconstants
Objectconstants
moduleutils
Objectutils
module
Production NODE_ENV and/or APP_ENV
Type: string
Test NODE_ENV
Type: string
CI NODE_ENV
Type: string
Development NODE_ENV
Type: string
QA APP_ENV
Type: string
Staging APP_ENV
Type: string
Preprod APP_ENV
Type: string
Get the app version from package.json
Parameters
Returns String
Get the application environment, defaults to development
Parameters
Returns String
Get the application deployment stage
Parameters
Returns String?
Is the application in development mode?
Parameters
Returns Boolean
Is the application deployed (NODE_ENV=production)
Parameters
Returns Boolean
Is the application in CI mode?
Parameters
Returns Boolean
Is the application in test mode?
Parameters
Returns Boolean
Is the application a qa deployment?
Parameters
Returns Boolean
Is the application a staging deployment?
Parameters
Returns Boolean
Is the application a preprod deployment?
Parameters
Returns Boolean
Is the application a production deployment?
Parameters
Returns Boolean
Is the application a heroku review app deployment?
Parameters
config
Object (optional, default{}
)config.IS_REVIEW_APP
any
Returns Boolean
Is the application running in a server runtime?
Parameters
config
Object (optional, default{}
)config.SERVER
any
Returns Boolean
Is the application running in a client runtime?
Parameters
config
Object (optional, default{}
)config.CLIENT
any
Returns Boolean
When building universal apps, it is common for a Node process to have sensitive information stored as environment variables. This isn't acceptable for client bundles, since they would be output in plaintext.
This utility serves to whitelist public keys.
It's output is meant for use with dotenv
and
something like webpack.DefinePlugin
Parameters
publicKeys
Array<String> keys from Nodeprocess.env
to inject into a client bundleconfig
Object (optional, defaultprocess.env
)
Examples
see `test/browser/webpack.config`, and the `npm run test:browser` target
Returns Object stringified object extracted from process.env
This is only useful for applications running on heroku
with the runtime-dyno-metadata
labs feature enabled and
is not included in the default output of env
Parameters
config
Object (optional, default{}
)config.HEROKU_APP_NAME
String The application name. "example-app"config.HEROKU_RELEASE_CREATED_AT
String The time and date the release was created. "2015-04-02T18:00:42Z"config.HEROKU_RELEASE_VERSION
String The identifier for the current release. "v42"config.HEROKU_SLUG_COMMIT
String The commit hash for the current release. "2c3a0b24069af49b3de35b8e8c26765c1dba9ff0"
Returns Object
Get the server host. Defaults to '0.0.0.0'
Parameters
Returns String
Get the server port. Defaults to '8080'
Parameters
Returns String