Skip to content

Commit 1bff591

Browse files
committed
chore(core): start of migrating config to yml
1 parent 413a7b0 commit 1bff591

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ node_modules
3131
#custom
3232
package-lock.json
3333
config.json
34+
config.yml
3435
import.csv
3536
/src/mailer/templates/promo/
3637
*.pem

.yarnclean

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ powered-test
66

77
# asset directories
88
docs
9-
doc
9+
#doc
1010
website
1111

1212
# examples

app.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (!process.env.FORK) {
4646
winston.info('Server Time: ' + new Date())
4747
}
4848

49-
let configFile = path.join(__dirname, '/config.json')
49+
let configFile = path.join(__dirname, '/config.yml')
5050

5151
nconf.defaults({
5252
base_dir: __dirname,
@@ -75,7 +75,8 @@ if (nconf.get('install') || (!configExists && !isDocker)) {
7575

7676
function loadConfig () {
7777
nconf.file({
78-
file: configFile
78+
file: configFile,
79+
format: require('nconf-yaml')
7980
})
8081
}
8182

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"mongoose-autopopulate": "0.16.0",
7777
"mongoose-lean-virtuals": "0.9.0",
7878
"nconf": "0.12.0",
79+
"nconf-yaml": "1.0.2",
7980
"netmask": "2.0.2",
8081
"node-cache": "5.1.2",
8182
"node-sass": "7.0.1",
@@ -121,7 +122,8 @@
121122
"util": "0.12.4",
122123
"velocity-react": "1.4.3",
123124
"winston": "3.6.0",
124-
"xss": "1.0.10"
125+
"xss": "1.0.10",
126+
"yaml": "2.1.1"
125127
},
126128
"devDependencies": {
127129
"@babel/core": "7.17.4",

src/controllers/install.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ installController.existingdb = function (req, res) {
9191
// Write Configfile
9292
const fs = require('fs')
9393
const chance = new Chance()
94-
const configFile = path.join(__dirname, '../../config.json')
95-
94+
const configFile = path.join(__dirname, '../../config.yml')
95+
const YAML = require('yaml')
9696
const conf = {
9797
mongo: {
9898
host: host,
@@ -107,7 +107,7 @@ installController.existingdb = function (req, res) {
107107
}
108108
}
109109

110-
fs.writeFile(configFile, JSON.stringify(conf, null, 4), function (err) {
110+
fs.writeFile(configFile, YAML.stringify(conf), function (err) {
111111
if (err) {
112112
winston.error('FS Error: ' + err.message)
113113
return res.status(400).json({ success: false, error: err.message })

src/settings/defaults.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,11 @@ function elasticSearchConfToDB (callback) {
592592
const nconf = require('nconf')
593593
const elasticsearch = {
594594
enable: nconf.get('elasticsearch:enable') || false,
595-
host: nconf.get('elasticsearch:host'),
596-
port: nconf.get('elasticsearch:port')
595+
host: nconf.get('elasticsearch:host') || "",
596+
port: nconf.get('elasticsearch:port') || 9200
597597
}
598598

599-
nconf.set('elasticsearch', undefined)
599+
nconf.set('elasticsearch', {})
600600

601601
async.parallel(
602602
[

yarn.lock

+13-1
Original file line numberDiff line numberDiff line change
@@ -8800,7 +8800,7 @@ [email protected], js-yaml@^4.1.0:
88008800
dependencies:
88018801
argparse "^2.0.1"
88028802

8803-
js-yaml@^3.13.1, js-yaml@~3.14.0:
8803+
js-yaml@^3.13.1, js-yaml@^3.2.3, js-yaml@~3.14.0:
88048804
version "3.14.1"
88058805
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
88068806
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
@@ -10592,6 +10592,13 @@ natural-compare@^1.4.0:
1059210592
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
1059310593
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
1059410594

10595+
10596+
version "1.0.2"
10597+
resolved "https://registry.yarnpkg.com/nconf-yaml/-/nconf-yaml-1.0.2.tgz#fea065333cf42b77a5e8060517969799d4156575"
10598+
integrity sha1-/qBlMzz0K3el6AYFF5aXmdQVZXU=
10599+
dependencies:
10600+
js-yaml "^3.2.3"
10601+
1059510602
1059610603
version "0.12.0"
1059710604
resolved "https://registry.yarnpkg.com/nconf/-/nconf-0.12.0.tgz#9cf70757aae4d440d43ed53c42f87da18471b8bf"
@@ -15977,6 +15984,11 @@ [email protected]:
1597715984
dependencies:
1597815985
"@babel/runtime" "^7.8.7"
1597915986

15987+
15988+
version "2.1.1"
15989+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.1.tgz#1e06fb4ca46e60d9da07e4f786ea370ed3c3cfec"
15990+
integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==
15991+
1598015992
yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.1:
1598115993
version "1.10.2"
1598215994
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"

0 commit comments

Comments
 (0)