Config loader fixed
This commit is contained in:
parent
dad9ed0287
commit
b6e8db9249
6 changed files with 63 additions and 6 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -32,4 +32,5 @@ lerna-debug.log*
|
||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
configs/main-config.jsonc
|
||||||
|
|
|
||||||
39
configs/main-config.jsonc.dist
Normal file
39
configs/main-config.jsonc.dist
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"mailListener": {
|
||||||
|
"issueNumberParser": "\\b(?<=#)\\d+\\b",
|
||||||
|
"imapSimpleConfig": {
|
||||||
|
"imap": {
|
||||||
|
"user": "",
|
||||||
|
"password": "",
|
||||||
|
"host": "",
|
||||||
|
"port": 143,
|
||||||
|
// tls: true,
|
||||||
|
"autotls": "always",
|
||||||
|
"authTimeout": 5000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"updateInterval": 180000, // 3 min
|
||||||
|
"boxName": "INBOX"
|
||||||
|
},
|
||||||
|
"rssListener": {
|
||||||
|
"subscriptions": [
|
||||||
|
{
|
||||||
|
"url": "",
|
||||||
|
"issueNumberParser": "\\b(?<=#)\\d+\\b"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"updateInterval": 600000 // 10 min
|
||||||
|
},
|
||||||
|
"issueChangesQueue": {
|
||||||
|
"updateInterval": 5000, // 5 sec
|
||||||
|
"itemsLimit": 3
|
||||||
|
},
|
||||||
|
"redmineUrlPrefix": "",
|
||||||
|
"webhooks": [
|
||||||
|
{
|
||||||
|
"url": "",
|
||||||
|
"apiKeyName": "",
|
||||||
|
"apiKeyValue": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,18 @@
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { parse } from 'jsonc-parser';
|
import { parse } from 'jsonc-parser';
|
||||||
import { MainConfigModel } from "../models/main-config-model";
|
import { MainConfigModel } from '../models/main-config-model';
|
||||||
|
|
||||||
export default (): MainConfigModel => {
|
export default (): MainConfigModel => {
|
||||||
const rawData = readFileSync(join(__dirname, '..', '..', 'configs', 'main-config.jsonc'), {encoding: "utf-8"});
|
const userDefinedConfigPath =
|
||||||
|
process.env['REDMINE_ISSUE_EVENT_EMITTER_CONFIG_PATH'];
|
||||||
|
const defaultConfigPath = 'configs';
|
||||||
|
const configPath = userDefinedConfigPath || defaultConfigPath;
|
||||||
|
|
||||||
|
const rawData = readFileSync(join(configPath, 'main-config.jsonc'), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
|
||||||
const data: MainConfigModel = parse(rawData);
|
const data: MainConfigModel = parse(rawData);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ export function random(min: number, max: number): number {
|
||||||
min = Math.ceil(min);
|
min = Math.ceil(min);
|
||||||
max = Math.floor(max);
|
max = Math.floor(max);
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
"@nestjs/config": "^2.0.0",
|
"@nestjs/config": "^2.0.0",
|
||||||
"@nestjs/core": "^8.0.0",
|
"@nestjs/core": "^8.0.0",
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@nestjs/platform-socket.io": "^8.4.4",
|
||||||
"@nestjs/serve-static": "^2.2.2",
|
"@nestjs/serve-static": "^2.2.2",
|
||||||
"@nestjs/websockets": "^8.4.4",
|
"@nestjs/websockets": "^8.4.4",
|
||||||
"imap-simple": "^5.1.0",
|
"imap-simple": "^5.1.0",
|
||||||
|
|
|
||||||
10
yarn.lock
10
yarn.lock
|
|
@ -659,6 +659,14 @@
|
||||||
multer "1.4.4"
|
multer "1.4.4"
|
||||||
tslib "2.3.1"
|
tslib "2.3.1"
|
||||||
|
|
||||||
|
"@nestjs/platform-socket.io@^8.4.4":
|
||||||
|
version "8.4.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/@nestjs/platform-socket.io/-/platform-socket.io-8.4.4.tgz#6fe10205387271b80027dd48cf9a986c1c397635"
|
||||||
|
integrity sha512-+/OE5W8J8K7oqNKBYAKa2e4c6OjKOsYN8XL0tBRk67yhB5/gtO93MV7IomAAVkOXPGi8u3sClxXxbSN3o5jywA==
|
||||||
|
dependencies:
|
||||||
|
socket.io "4.4.1"
|
||||||
|
tslib "2.3.1"
|
||||||
|
|
||||||
"@nestjs/schematics@^8.0.0", "@nestjs/schematics@^8.0.3":
|
"@nestjs/schematics@^8.0.0", "@nestjs/schematics@^8.0.3":
|
||||||
version "8.0.9"
|
version "8.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/@nestjs/schematics/-/schematics-8.0.9.tgz#796e06c14ba43930abb12cde0e0144b16925a6a3"
|
resolved "https://registry.yarnpkg.com/@nestjs/schematics/-/schematics-8.0.9.tgz#796e06c14ba43930abb12cde0e0144b16925a6a3"
|
||||||
|
|
@ -4454,7 +4462,7 @@ socket.io-parser@~4.0.4:
|
||||||
component-emitter "~1.3.0"
|
component-emitter "~1.3.0"
|
||||||
debug "~4.3.1"
|
debug "~4.3.1"
|
||||||
|
|
||||||
socket.io@^4.4.1:
|
socket.io@4.4.1, socket.io@^4.4.1:
|
||||||
version "4.4.1"
|
version "4.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.4.1.tgz#cd6de29e277a161d176832bb24f64ee045c56ab8"
|
resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.4.1.tgz#cd6de29e277a161d176832bb24f64ee045c56ab8"
|
||||||
integrity sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==
|
integrity sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue