@rapido/env
This package includes modules to manage environment variables in Rapido apps.
Please refer to the Rapido documentation:
- Getting Started – How to create a new app.
- User Guide – How to develop apps bootstrapped with Rapido.
Installation
yarn add @rapido/env
Getting Started
// First initialize the env (e.g. during build process)
import initEnv from '@rapido/env/init';
// First initialize
initEnv({ NODE_ENV: 'development' });
// Later in code you can access env vars after the package has been initialized
import getEnv from '@rapido/env';
console.log(getEnv('NODE_ENV'));
API
initEnv(envars: { [key: string]: string }): void
Accepts an object of environment values and stores them for later.
import initEnv from '@rapido/env/init';
initEnv({ NODE_ENV: 'development' });
getEnv(key: string): string
Accepts a key string and returns the env variable value for that key.
import getEnv from '@rapido/env';
console.log(getEnv('NODE_ENV'));