asclepius-standard
Advanced tools
Comparing version 1.0.2 to 1.1.0-alpha.0
36
index.js
const asclepius = require('asclepius'); | ||
const nullLogger = require('null-logger'); | ||
const sequelizeHealthcheck = (sequelize, logger = nullLogger) => asclepius.healthcheck( | ||
const defaultTimeout = 500; | ||
const sequelizeHealthcheck = (sequelize, logger = nullLogger, timeout = defaultTimeout) => asclepius.healthcheck( | ||
'psql', | ||
@@ -14,6 +16,6 @@ () => | ||
}), | ||
500 | ||
timeout | ||
); | ||
const redisHealthcheck = (redis, logger = nullLogger) => asclepius.healthcheck( | ||
const redisHealthcheck = (redis, logger = nullLogger, timeout = defaultTimeout) => asclepius.healthcheck( | ||
'redis', | ||
@@ -30,6 +32,6 @@ () => | ||
}), | ||
500 | ||
timeout | ||
); | ||
const elasticsearchHealthcheck = (elasticsearch, logger = nullLogger) => asclepius.healthcheck( | ||
const elasticsearchHealthcheck = (elasticsearch, logger = nullLogger, timeout = defaultTimeout) => asclepius.healthcheck( | ||
'elasticsearch', | ||
@@ -44,3 +46,3 @@ () => | ||
}), | ||
500 | ||
timeout | ||
); | ||
@@ -51,14 +53,24 @@ | ||
() => Promise.resolve(), | ||
500 | ||
defaultTimeout | ||
); | ||
module.exports = { | ||
setup: ({ sequelize = null, redis = null, elasticsearch = null, logger = nullLogger } = {}) => { | ||
const _buildHealthCheckArray = ({ sequelize = null, redis = null, elasticsearch = null, logger = nullLogger, timeout = defaultTimeout } = {}) => { | ||
const healthchecks = [processHealthcheck]; | ||
if (sequelize) healthchecks.push(sequelizeHealthcheck(sequelize, logger)); | ||
if (elasticsearch) healthchecks.push(elasticsearchHealthcheck(elasticsearch, logger)); | ||
if (redis) healthchecks.push(redisHealthcheck(redis, logger)); | ||
if (sequelize) healthchecks.push(sequelizeHealthcheck(sequelize, logger, timeout)); | ||
if (elasticsearch) healthchecks.push(elasticsearchHealthcheck(elasticsearch, logger, timeout)); | ||
if (redis) healthchecks.push(redisHealthcheck(redis, logger, timeout)); | ||
return healthchecks; | ||
} | ||
module.exports = { | ||
setup: ({ sequelize = null, redis = null, elasticsearch = null, logger = nullLogger, timeout = defaultTimeout } = {}) => { | ||
const healthchecks = _buildHealthCheckArray({ sequelize, redis, elasticsearch, logger, timeout }); | ||
return asclepius.makeRoute(healthchecks); | ||
}, | ||
runner: ({ sequelize = null, redis = null, elasticsearch = null, logger = nullLogger, timeout = defaultTimeout } = {}) => { | ||
const healthchecks = _buildHealthCheckArray({ sequelize, redis, elasticsearch, logger, timeout }); | ||
return asclepius.makeRunner(healthchecks); | ||
} | ||
}; |
{ | ||
"name": "asclepius-standard", | ||
"version": "1.0.2", | ||
"version": "1.1.0-alpha.0", | ||
"description": "Asclepius Standard Configuration", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:ordermentum/asclepius-standard.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
3118
68
1
20
3