$ gnpm install snyk-config
Loads the configuration for your module.
Although you can require this module directly, it's recommended you create your
own config.ts
file that can be cached by the require system and called without a path:
// config.ts
import { loadConfig } from 'snyk-config';
export const config = loadConfig('<directory with config files>');
// in app.ts
import { config } from './config';
// in foo.ts
import { config } from './config'; // matches config in app.ts
The config loader will look for the following values in order of priority, specifically, if a property appears in multiple layers of config (below) the first found is used:
SNYK_
config.secret.json
file in the path specified by:
secretConfig
option, orCONFIG_SECRET_FILE
, orconfig.${SERVICE_ENV}.json
file in the specified config directory,
SERVICE_ENV
defaults to local
, if not setconfig.default.json
file in the specified config directory{
"from": "file"
}
import { loadConfig } from 'snyk-config';
// as we're in the same directory as the config.local.json, there's no arg
const config = loadConfig();
console.log(config);
$ SNYK_from=cli node app.js
=> { from: "cli" }
strings
or boolean
s. This is important to differentiate from values parsed in the config files
as these can be numbers
.SNYK_
string, so SNYK_foo = 10
becomes foo = "10"
SNYK_foo__bar = 10
becomes foo = { bar: "10" }
Copyright 2013 - present © cnpmjs.org | Home |