express-status-monitor
Advanced tools
Comparing version 1.2.3 to 1.2.5
@@ -6,2 +6,6 @@ { | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 8 | ||
}, | ||
"extends": "eslint:recommended", | ||
@@ -65,6 +69,2 @@ "rules": { | ||
"func-names": "error", | ||
"func-style": [ | ||
"error", | ||
"expression" | ||
], | ||
"generator-star-spacing": "error", | ||
@@ -71,0 +71,0 @@ "global-require": "error", |
@@ -16,6 +16,6 @@ { | ||
"dependencies": { | ||
"express": "^4.14.0", | ||
"express-favicon-short-circuit": "^1.1.0", | ||
"request": "^2.87.0", | ||
"socket.io": "^2.1.0" | ||
"express": "4.16.4", | ||
"express-favicon-short-circuit": "1.1.1", | ||
"request": "2.88.0", | ||
"socket.io": "2.2.0" | ||
}, | ||
@@ -30,2 +30,2 @@ "scripts": { | ||
} | ||
} | ||
} |
{ | ||
"name": "express-status-monitor", | ||
"version": "1.2.3", | ||
"version": "1.2.5", | ||
"description": "Realtime Monitoring for Express-based Node applications", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=8" | ||
}, | ||
@@ -48,2 +48,7 @@ "author": "Rafal Wilinski <raf.wilinski@gmail.com> (http://rwilinski.me)", | ||
"url": "https://github.com/capaj/" | ||
}, | ||
{ | ||
"name": "Max Findel", | ||
"email": "max@terminal.co", | ||
"url": "https://github.com/maxfindel/" | ||
} | ||
@@ -57,16 +62,14 @@ ], | ||
"dependencies": { | ||
"debug": "^2.6.8", | ||
"handlebars": "~4.0.12", | ||
"on-headers": "^1.0.1", | ||
"pidusage": "^1.1.6", | ||
"request-promise-native": "^1.0.5", | ||
"socket.io": "^2.0.3" | ||
"axios": "0.18.0", | ||
"debug": "4.1.1", | ||
"handlebars": "4.1.2", | ||
"on-headers": "1.0.2", | ||
"pidusage": "2.0.17", | ||
"request": "2.88.0", | ||
"socket.io": "2.2.0" | ||
}, | ||
"scripts": { | ||
"coverage": "istanbul cover _mocha test -- --recursive", | ||
"test-ci": "mocha --recursive", | ||
"test": "mocha --recursive --watch", | ||
"snyk-protect": "snyk protect", | ||
"publish": "publish", | ||
"prepublish": "npm run snyk-protect", | ||
"example": "npm i && npm i --prefix examples && npm start --prefix examples", | ||
@@ -76,12 +79,9 @@ "eslint": "eslint ." | ||
"devDependencies": { | ||
"bithound": "^1.7.0", | ||
"chai": "^4.1.0", | ||
"eslint": "^4.3.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.4.2", | ||
"publish": "^0.6.0", | ||
"sinon": "^2.4.1", | ||
"snyk": "^1.37.0" | ||
"chai": "4.2.0", | ||
"eslint": "5.16.0", | ||
"mocha": "6.1.3", | ||
"sinon": "7.3.1", | ||
"snyk": "1.151.0" | ||
}, | ||
"snyk": true | ||
} |
@@ -45,3 +45,5 @@ # express-status-monitor | ||
title: 'Express Status', // Default title | ||
theme: 'default.css', // Default styles | ||
path: '/status', | ||
socketPath: '/socket.io', // In case you use a custom path | ||
websocket: existingSocketIoInstance, | ||
@@ -48,0 +50,0 @@ spans: [{ |
module.exports = { | ||
title: 'Express Status', | ||
theme: 'default.css', | ||
path: '/status', | ||
socketPath: '/socket.io', | ||
spans: [ | ||
@@ -5,0 +7,0 @@ { |
@@ -17,3 +17,3 @@ const pidusage = require('pidusage'); | ||
pidusage.stat(process.pid, (err, stat) => { | ||
pidusage(process.pid, (err, stat) => { | ||
if (err) { | ||
@@ -20,0 +20,0 @@ debug(err); |
'use strict'; | ||
const request = require('request-promise-native'); | ||
const axios = require('axios'); | ||
module.exports = async (healthChecks) => { | ||
healthChecks = healthChecks || []; | ||
function allSettled (promises) { | ||
const wrappedPromises = promises.map(p => Promise.resolve(p) | ||
.then( | ||
val => ({ state: 'fulfilled', value: val }), | ||
err => ({ state: 'rejected', reason: err }) | ||
) | ||
); | ||
return Promise.all(wrappedPromises); | ||
} | ||
module.exports = async healthChecks => { | ||
const checkPromises = []; | ||
healthChecks.forEach(healthCheck => { | ||
(healthChecks || []).forEach(healthCheck => { | ||
let uri = `${healthCheck.protocol}://${healthCheck.host}`; | ||
if (healthCheck.port) { | ||
@@ -19,4 +29,4 @@ uri += `:${healthCheck.port}`; | ||
checkPromises.push(request({ | ||
uri: uri, | ||
checkPromises.push(axios({ | ||
url: uri, | ||
method: 'GET' | ||
@@ -26,5 +36,5 @@ })); | ||
let checkResults = []; | ||
const checkResults = []; | ||
return _allSettled(checkPromises).then((results) => { | ||
return allSettled(checkPromises).then(results => { | ||
results.forEach((result, index) => { | ||
@@ -47,9 +57,1 @@ if (result.state === 'rejected') { | ||
}; | ||
function _allSettled(promises) { | ||
let wrappedPromises = promises.map(p => Promise.resolve(p) | ||
.then( | ||
val => ({ state: 'fulfilled', value: val }), | ||
err => ({ state: 'rejected', reason: err }))); | ||
return Promise.all(wrappedPromises); | ||
} |
@@ -19,4 +19,8 @@ const defaultConfig = require('./default-config'); | ||
typeof config.title === 'string' ? config.title : defaultConfig.title; | ||
config.theme = | ||
typeof config.theme === 'string' ? config.theme : defaultConfig.theme; | ||
config.path = | ||
typeof config.path === 'string' ? config.path : defaultConfig.path; | ||
config.socketPath = | ||
typeof config.socketPath === 'string' ? config.socketPath : defaultConfig.socketPath; | ||
config.spans = | ||
@@ -40,3 +44,3 @@ typeof config.spans === 'object' ? config.spans : defaultConfig.spans; | ||
: defaultConfig.ignoreStartsWith; | ||
config.healthChecks = | ||
@@ -43,0 +47,0 @@ Array.isArray(config.healthChecks) |
@@ -12,3 +12,2 @@ const fs = require('fs'); | ||
const validatedConfig = validate(config); | ||
const bodyClasses = Object.keys(validatedConfig.chartVisibility) | ||
@@ -22,9 +21,10 @@ .reduce((accumulator, key) => { | ||
.join(' '); | ||
const data = { | ||
title: validatedConfig.title, | ||
port: validatedConfig.port, | ||
bodyClasses: bodyClasses, | ||
socketPath: validatedConfig.socketPath, | ||
bodyClasses, | ||
script: fs.readFileSync(path.join(__dirname, '/public/javascripts/app.js')), | ||
style: fs.readFileSync(path.join(__dirname, '/public/stylesheets/style.css')) | ||
style: fs.readFileSync(path.join(__dirname, '/public/stylesheets/', validatedConfig.theme)) | ||
}; | ||
@@ -44,6 +44,4 @@ | ||
if (req.path === validatedConfig.path) { | ||
healthChecker(validatedConfig.healthChecks).then((results) => { | ||
healthChecker(validatedConfig.healthChecks).then(results => { | ||
data.healthCheckResults = results; | ||
if (validatedConfig.iframe) { | ||
@@ -53,2 +51,3 @@ if (res.removeHeader) { | ||
} | ||
if (res.remove) { | ||
@@ -58,2 +57,3 @@ res.remove('X-Frame-Options'); | ||
} | ||
res.send(render(data)); | ||
@@ -84,3 +84,3 @@ }); | ||
middleware.pageRoute = (req, res) => { | ||
healthChecker(validatedConfig.healthChecks).then((results) => { | ||
healthChecker(validatedConfig.healthChecks).then(results => { | ||
data.healthCheckResults = results; | ||
@@ -87,0 +87,0 @@ res.send(render(data)); |
@@ -5,3 +5,3 @@ /* | ||
*/ | ||
/* global Chart, location, document, port, parseInt, io */ | ||
/* global Chart, location, document, port, socketPath, parseInt, io */ | ||
@@ -17,3 +17,3 @@ 'use strict'; | ||
var socket = io(location.protocol + '//' + location.hostname + ':' + (port || location.port)); | ||
var socket = io(location.protocol + '//' + location.hostname + ':' + (port || location.port), { path: socketPath }); | ||
var defaultSpan = 0; | ||
@@ -20,0 +20,0 @@ var spans = []; |
@@ -66,5 +66,2 @@ const chai = require('chai'); | ||
}); | ||
}); | ||
@@ -71,0 +68,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
5
138
49778
7
27
1185
+ Addedaxios@0.18.0
+ Addedrequest@2.88.0
+ Addedasync-limiter@1.0.1(transitive)
+ Addedaxios@0.18.0(transitive)
+ Addedbase64-arraybuffer@0.1.5(transitive)
+ Addedbase64id@1.0.0(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcookie@0.3.1(transitive)
+ Addedengine.io@3.3.2(transitive)
+ Addedengine.io-client@3.3.3(transitive)
+ Addedengine.io-parser@2.1.3(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedhandlebars@4.1.2(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedobject-component@0.0.3(transitive)
+ Addedparseqs@0.0.5(transitive)
+ Addedparseuri@0.0.5(transitive)
+ Addedpidusage@2.0.17(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedrequest@2.88.0(transitive)
+ Addedsocket.io@2.2.0(transitive)
+ Addedsocket.io-client@2.2.0(transitive)
+ Addedtough-cookie@2.4.3(transitive)
+ Addedws@6.1.4(transitive)
- Removedrequest-promise-native@^1.0.5
- Removedasync@2.6.4(transitive)
- Removedbase64-arraybuffer@0.1.4(transitive)
- Removedbase64id@2.0.0(transitive)
- Removedcookie@0.4.2(transitive)
- Removeddebug@2.6.9(transitive)
- Removedengine.io@3.6.2(transitive)
- Removedengine.io-client@3.5.4(transitive)
- Removedengine.io-parser@2.2.1(transitive)
- Removedhandlebars@4.0.14(transitive)
- Removedlodash@4.17.21(transitive)
- Removedparseqs@0.0.6(transitive)
- Removedparseuri@0.0.6(transitive)
- Removedpidusage@1.2.0(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequest-promise-native@1.0.9(transitive)
- Removedsocket.io@2.5.1(transitive)
- Removedsocket.io-client@2.5.0(transitive)
- Removedsocket.io-parser@3.4.3(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedws@7.5.10(transitive)
Updateddebug@4.1.1
Updatedhandlebars@4.1.2
Updatedon-headers@1.0.2
Updatedpidusage@2.0.17
Updatedsocket.io@2.2.0