Use config package's multi-directory built-in support

This avoids full object overriding when you just want to set specific fields
This commit is contained in:
Alice Gaudon 2020-09-03 08:28:57 +02:00
parent f45daa4a9f
commit 54faa5c873
6 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,4 @@
export default Object.assign(require("wms-core/config/default").default, { export default {
app: { app: {
name: 'Example App', name: 'Example App',
contact_email: 'contact@example.net' contact_email: 'contact@example.net'
@ -42,4 +42,4 @@ export default Object.assign(require("wms-core/config/default").default, {
cache: false cache: false
}, },
approval_mode: false, approval_mode: false,
}); }

View File

@ -1,4 +1,4 @@
export default Object.assign(require("wms-core/config/production").default, { export default {
log_level: "DEBUG", log_level: "DEBUG",
db_log_level: "ERROR", db_log_level: "ERROR",
public_url: "https://watch-my.stream", public_url: "https://watch-my.stream",
@ -12,4 +12,4 @@ export default Object.assign(require("wms-core/config/production").default, {
secure: true, secure: true,
allow_invalid_tls: false allow_invalid_tls: false
} }
}); }

View File

@ -1,4 +1,4 @@
export default Object.assign(require("wms-core/config/test").default, { export default {
mysql: { mysql: {
host: "localhost", host: "localhost",
user: "root", user: "root",
@ -6,4 +6,4 @@ export default Object.assign(require("wms-core/config/test").default, {
database: "wms2_test", database: "wms2_test",
create_database_automatically: true create_database_automatically: true
} }
}); }

View File

@ -9,7 +9,7 @@
"scripts": { "scripts": {
"test": "jest --verbose --runInBand", "test": "jest --verbose --runInBand",
"dist-webpack": "webpack --mode production", "dist-webpack": "webpack --mode production",
"dist": "tsc && npm run dist-webpack", "dist": "(test ! -d dist || rm -r dist) && tsc && npm run dist-webpack && mkdir -p dist/core-config && cp -r node_modules/wms-core/config/* dist/core-config/",
"dev": "concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"", "dev": "concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"",
"start": "yarn dist && node dist/main.js" "start": "yarn dist && node dist/main.js"
}, },

View File

@ -1,3 +1,9 @@
// Load config from specified path or default + wms-core/config (default defaults)
process.env['NODE_CONFIG_DIR'] =
(process.env['NODE_CONFIG_DIR'] || './config/')
+ require('path').delimiter
+ __dirname + '/core-config/';
import Logger from "wms-core/Logger"; import Logger from "wms-core/Logger";
import App from "./App"; import App from "./App";
import config from "config"; import config from "config";

View File

@ -13,7 +13,6 @@
] ]
}, },
"include": [ "include": [
"src/**/*", "src/**/*"
"node_modules/wms-core"
] ]
} }