Skip to content

Commit

Permalink
default config add path
Browse files Browse the repository at this point in the history
  • Loading branch information
tortuvshin committed Jan 17, 2018
1 parent 6a00ade commit 0f852a6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "techstar-uptime",
"version": "1.0.3",
"version": "1.0.4",
"description": "Uptime monitor",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/default-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
path: '/uptime',
url: 'https://www.techstar.cloud', // URL of service we'll be pining
timeout: 200, // threshold in milliseconds above which is considered degraded performance
SLACK_WEBHOOK_URL: ""
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = config => {
return defaultConfig;
}

config.url = (typeof config.url === 'object') ? config.url : defaultConfig.url;
config.path = (typeof config.path === 'string') ? config.path : defaultConfig.path;
config.url = (typeof config.url === 'string') ? config.url : defaultConfig.url;
config.timeout = (typeof config.timeout === 'number') ? config.timeout : defaultConfig.timeout;
config.SLACK_WEBHOOK_URL = (typeof config.SLACK_WEBHOOK_URL === 'string') ? config.SLACK_WEBHOOK_URL : defaultConfig.SLACK_WEBHOOK_URL;

Expand Down
2 changes: 1 addition & 1 deletion src/middleware-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const middlewareWrapper = config => {

if (avgResTime > currService.timeout && currService.status !== 'DEGRADED') {
currService.status = 'DEGRADED'
postToSlack(service.url)
postToSlack(validatedConfig.url)
} else if (avgResTime < currService.timeout && currService.status !== 'OPERATIONAL') {
currService.status = 'OPERATIONAL'
postToSlack(validatedConfig.url)
Expand Down

0 comments on commit 0f852a6

Please sign in to comment.