-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
41 lines (35 loc) · 1023 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const startup = require('./src/startup');
const Check = require('./src/checks/check');
const status = require('./src/checks/status');
const checks = require('./src/checks');
function categoryInCheckName(healthCheck, check) {
check.name = healthCheck.name + ': ' + check.name;
return check;
}
module.exports = function (config, additionalChecks) {
let healthCheckMap = startup(config, additionalChecks);
return {
asMap: () => healthCheckMap,
asArray: () => {
let healthCheckArray = [];
for (let healthCheck of healthCheckMap.values()) {
let checks = healthCheck.checks.map(
categoryInCheckName.bind(null, healthCheck)
);
healthCheckArray = healthCheckArray.concat(checks);
}
return healthCheckArray;
}
};
};
module.exports.Check = Check;
module.exports.status = status;
module.exports.getCheck = (conf) => {
return new checks[conf.type](conf);
};
module.exports.runCheck = (conf) => {
const check = new checks[conf.type](conf);
check.start();
return check;
};