Config
Configuration settings are stored within a JSON object located inside the /config folder. You can add multiple config files here for each development environment that you're using.
Gravity ships with default and production config files to get you started.
Using this approach will enable you to load the correct configuration depending on your environment. For example, you can load your test Stripe API keys in your local development environment and your live keys when running in production.
Use a filename that matches your node_env name to load that config file in that environment.
To access the key value pairs in the config file within your code, you first need to import the config file. First, import the config package and then get the specific object you want from the config file.
const config = require('config');
const settings = config.get('stripe');
This will import the Stripe settings from the config file loaded in your current environment.
You should store sensitive config items like passwords and secrets inside an environment variable in your server for increased security.
Last modified 2yr ago