Обновлена конфигурация основного приложения и загрузчик конфигурации
This commit is contained in:
parent
4928357e8a
commit
a49f89bf97
2 changed files with 28 additions and 15 deletions
7
configs/main-config.jsonc.dist
Normal file
7
configs/main-config.jsonc.dist
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"couchDb": {
|
||||||
|
"dbs": {
|
||||||
|
"changes": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,23 +1,29 @@
|
||||||
import RedmineIssueEventEmitterConfigLoader from '@app/event-emitter/configs/main-config';
|
import RedmineIssueEventEmitterConfigLoader from '@app/event-emitter/configs/main-config';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { parse } from 'jsonc-parser';
|
||||||
|
|
||||||
const redmineIssueEventEmitterConfig = RedmineIssueEventEmitterConfigLoader();
|
const redmineIssueEventEmitterConfig = RedmineIssueEventEmitterConfigLoader();
|
||||||
|
|
||||||
const appConfig = {
|
let appConfig;
|
||||||
couchDbUrl:
|
|
||||||
process.env['ELTEX_REDMINE_HELPER_COUCHDB_URL'] || 'http://localhost:5984',
|
|
||||||
|
|
||||||
dbs: {
|
export default () => {
|
||||||
issues:
|
if (appConfig) {
|
||||||
process.env['ELTEX_REDMINE_HELPER_COUCHDB_ISSUES_DB_NAME'] ||
|
return appConfig;
|
||||||
'redmine_issues',
|
}
|
||||||
users:
|
|
||||||
process.env['ELTEX_REDMINE_HELPER_COUCHDB_USERS_DB_NAME'] ||
|
|
||||||
'redmine_users',
|
|
||||||
},
|
|
||||||
|
|
||||||
|
const userDefinedConfigPath = process.env['ELTEX_REDMINE_HELPER_CONFIG_PATH'];
|
||||||
|
const defaultConfigPath = join('configs', 'main-config.jsonc');
|
||||||
|
const configPath = userDefinedConfigPath || defaultConfigPath;
|
||||||
|
|
||||||
|
const rawData = readFileSync(configPath, { encoding: 'utf-8' });
|
||||||
|
|
||||||
|
const data = parse(rawData);
|
||||||
|
|
||||||
|
appConfig = {
|
||||||
|
...data,
|
||||||
redmineIssueEventEmitterConfig: redmineIssueEventEmitterConfig,
|
redmineIssueEventEmitterConfig: redmineIssueEventEmitterConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default () => {
|
|
||||||
return appConfig;
|
return appConfig;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue