-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
38 lines (34 loc) · 918 Bytes
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
const convict = require('convict');
const toml = require('toml');
const config = convict({
env: {
doc: "The application environment.",
format: ["prod", "testing", "dev"],
default: "dev",
env: "NODE_ENV"
},
username: {
doc: 'The username of the test account',
default: '',
format: String,
env: "AUTHLESS_TEST_USERNAME"
},
password: {
doc: 'The password of the test account',
default: '',
format: String,
env: "AUTHLESS_TEST_PASSWORD",
sensitive: true
}
});
// Load environment dependent configuration
// this needs to be like this for parcel bundler to work correctly
const configPath = `config/${config.get('env')}.toml`;
if (fs.existsSync(configPath)) {
const tomlEnv = fs.readFileSync(configPath);
config.load(toml.parse(tomlEnv));
}
// Perform validation
config.validate({allowed: 'strict'});
module.exports = config