express-status-monitor
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -12,15 +12,22 @@ /* eslint no-console: "off" */ | ||
app.use(require('../index')({ | ||
path: '/', | ||
// Use existing socket.io instance. | ||
// websocket: socketio, | ||
app.use( | ||
require('../index')({ | ||
path: '/', | ||
// Use existing socket.io instance. | ||
// websocket: socketio, | ||
// Pass socket.io instance port down to config. | ||
// Use only if you're passing your own instance. | ||
// port: socketIoPort, | ||
})); | ||
// Ignore requests which req.path begins with | ||
// ignoreStartsWith: '/return-status', | ||
// Pass socket.io instance port down to config. | ||
// Use only if you're passing your own instance. | ||
// port: socketIoPort, | ||
}), | ||
); | ||
app.use(require('express-favicon-short-circuit')); | ||
// Example route throwing requested status code | ||
app.get('/return-status/:statusCode', (req, res) => res.sendStatus(req.params.statusCode)); | ||
app.get('/return-status/:statusCode', (req, res) => | ||
res.sendStatus(req.params.statusCode), | ||
); | ||
@@ -27,0 +34,0 @@ app.listen(port, () => { |
{ | ||
"name": "express-status-monitor", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Realtime Monitoring for Express-based Node applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,3 +64,4 @@ # express-status-monitor | ||
statusCodes: true | ||
} | ||
}, | ||
ignoreStartsWith: '/admin' | ||
@@ -67,0 +68,0 @@ ``` |
@@ -27,4 +27,5 @@ module.exports = { | ||
rps: true, | ||
statusCodes: true | ||
} | ||
statusCodes: true, | ||
}, | ||
ignoreStartsWith: '', | ||
}; |
@@ -17,11 +17,26 @@ const defaultConfig = require('./default-config'); | ||
config.title = (typeof config.title === 'string') ? config.title : defaultConfig.title; | ||
config.path = (typeof config.path === 'string') ? config.path : defaultConfig.path; | ||
config.spans = (typeof config.spans === 'object') ? config.spans : defaultConfig.spans; | ||
config.port = (typeof config.port === 'number') ? config.port : defaultConfig.port; | ||
config.websocket = (typeof config.websocket === 'object') ? config.websocket : defaultConfig.websocket; | ||
config.iframe = (typeof config.iframe === 'boolean') ? config.iframe : defaultConfig.iframe; | ||
config.chartVisibility = (typeof config.chartVisibility === 'object') ? mungeChartVisibility(config.chartVisibility) : defaultConfig.chartVisibility; | ||
config.title = | ||
typeof config.title === 'string' ? config.title : defaultConfig.title; | ||
config.path = | ||
typeof config.path === 'string' ? config.path : defaultConfig.path; | ||
config.spans = | ||
typeof config.spans === 'object' ? config.spans : defaultConfig.spans; | ||
config.port = | ||
typeof config.port === 'number' ? config.port : defaultConfig.port; | ||
config.websocket = | ||
typeof config.websocket === 'object' | ||
? config.websocket | ||
: defaultConfig.websocket; | ||
config.iframe = | ||
typeof config.iframe === 'boolean' ? config.iframe : defaultConfig.iframe; | ||
config.chartVisibility = | ||
typeof config.chartVisibility === 'object' | ||
? mungeChartVisibility(config.chartVisibility) | ||
: defaultConfig.chartVisibility; | ||
config.ignoreStartsWith = | ||
typeof config.path === 'string' | ||
? config.ignoreStartsWith | ||
: defaultConfig.ignoreStartsWith; | ||
return config; | ||
}; |
@@ -11,17 +11,25 @@ const fs = require('fs'); | ||
const bodyClasses = Object.keys(validatedConfig.chartVisibility).reduce((accumulator, key) => { | ||
if (validatedConfig.chartVisibility[key] === false) { | ||
accumulator.push(`hide-${key}`); | ||
} | ||
return accumulator; | ||
}, []).join(' '); | ||
const bodyClasses = Object.keys(validatedConfig.chartVisibility) | ||
.reduce((accumulator, key) => { | ||
if (validatedConfig.chartVisibility[key] === false) { | ||
accumulator.push(`hide-${key}`); | ||
} | ||
return accumulator; | ||
}, []) | ||
.join(' '); | ||
const renderedHtml = | ||
fs.readFileSync(path.join(__dirname, '/public/index.html')) | ||
.toString() | ||
.replace(/{{title}}/g, validatedConfig.title) | ||
.replace(/{{port}}/g, validatedConfig.port) | ||
.replace(/{{bodyClasses}}/g, bodyClasses) | ||
.replace(/{{script}}/g, fs.readFileSync(path.join(__dirname, '/public/javascripts/app.js'))) | ||
.replace(/{{style}}/g, fs.readFileSync(path.join(__dirname, '/public/stylesheets/style.css'))); | ||
const renderedHtml = fs | ||
.readFileSync(path.join(__dirname, '/public/index.html')) | ||
.toString() | ||
.replace(/{{title}}/g, validatedConfig.title) | ||
.replace(/{{port}}/g, validatedConfig.port) | ||
.replace(/{{bodyClasses}}/g, bodyClasses) | ||
.replace( | ||
/{{script}}/g, | ||
fs.readFileSync(path.join(__dirname, '/public/javascripts/app.js')), | ||
) | ||
.replace( | ||
/{{style}}/g, | ||
fs.readFileSync(path.join(__dirname, '/public/stylesheets/style.css')), | ||
); | ||
@@ -41,9 +49,10 @@ const middleware = (req, res, next) => { | ||
} | ||
} | ||
res.send(renderedHtml); | ||
} else { | ||
onHeaders(res, () => { | ||
onHeadersListener(res.statusCode, startTime, validatedConfig.spans); | ||
}); | ||
if (!req.path.startsWith(validatedConfig.ignoreStartsWith)) { | ||
onHeaders(res, () => { | ||
onHeadersListener(res.statusCode, startTime, validatedConfig.spans); | ||
}); | ||
} | ||
@@ -50,0 +59,0 @@ next(); |
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
45600
1061
114