Browse Source

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

This avoids full object overriding when you just want to set specific fields
develop
Alice Gaudon 9 months ago
parent
commit
54faa5c873
6 changed files with 14 additions and 9 deletions
  1. +2
    -2
      config/default.ts
  2. +2
    -2
      config/production.ts
  3. +2
    -2
      config/test.ts
  4. +1
    -1
      package.json
  5. +6
    -0
      src/main.ts
  6. +1
    -2
      tsconfig.json

+ 2
- 2
config/default.ts View File

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

+ 2
- 2
config/production.ts View File

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

+ 2
- 2
config/test.ts View File

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

+ 1
- 1
package.json View File

@ -9,7 +9,7 @@
"scripts": {
"test": "jest --verbose --runInBand",
"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\"",
"start": "yarn dist && node dist/main.js"
},


+ 6
- 0
src/main.ts 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 App from "./App";
import config from "config";


+ 1
- 2
tsconfig.json View File

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

Loading…
Cancel
Save