express-status-monitor
Advanced tools
Comparing version 0.0.11 to 0.1.0
@@ -22,3 +22,3 @@ const express = require('express'); | ||
app.listen(3000, () => { | ||
console.log('🌏 http://0.0.0.0:3000'); | ||
console.log('Listening on http://0.0.0.0:3000'); | ||
}); |
26
index.js
@@ -8,3 +8,2 @@ 'use strict'; | ||
const pidusage = require('pidusage'); | ||
const basicAuth = require('basic-auth'); | ||
let io; | ||
@@ -15,6 +14,2 @@ | ||
path: '/status', | ||
auth: { | ||
username: '', | ||
password: '' | ||
}, | ||
spans: [{ | ||
@@ -69,7 +64,2 @@ interval: 1, | ||
const unauthorized = (res) => { | ||
res.set('WWW-Authenticate', 'Basic realm=Authorization Required'); | ||
return res.send(401); | ||
}; | ||
const middlewareWrapper = (config) => { | ||
@@ -92,11 +82,8 @@ if (config === null || config === undefined) { | ||
if (config.auth === undefined || !config.auth instanceof Object | ||
|| config.auth.username === undefined || !config.auth.username instanceof String || config.auth.username === '' | ||
|| config.auth.password === undefined || !config.auth.password instanceof String || config.auth.password === '') { | ||
config.auth = false; | ||
} | ||
let renderedHtml; | ||
fs.readFile(path.join(__dirname, '/index.html'), function (err, html) { | ||
renderedHtml = html.toString().replace(/{{title}}/g, config.title); | ||
renderedHtml = html.toString() | ||
.replace(/{{title}}/g, config.title) | ||
.replace(/{{script}}/g, fs.readFileSync(path.join(__dirname, '/app.js'))) | ||
.replace(/{{style}}/g, fs.readFileSync(path.join(__dirname, '/style.css'))); | ||
}); | ||
@@ -125,7 +112,2 @@ | ||
if (req.path === config.path) { | ||
if (config.auth) { | ||
var user = basicAuth(req); | ||
if (!user || !user.name || !user.pass) return unauthorized(res); | ||
if (user.name !== config.auth.username || user.pass !== config.auth.password) return unauthorized(res); | ||
} | ||
res.send(renderedHtml); | ||
@@ -132,0 +114,0 @@ } else { |
{ | ||
"name": "express-status-monitor", | ||
"version": "0.0.11", | ||
"version": "0.1.0", | ||
"description": "Realtime Monitoring for Express-based Node applications", | ||
"main": "app.js", | ||
"main": "index.js", | ||
"keywords": [ | ||
@@ -32,3 +32,2 @@ "node", | ||
"dependencies": { | ||
"basic-auth": "^1.0.4", | ||
"on-headers": "^1.0.1", | ||
@@ -35,0 +34,0 @@ "pidusage": "^1.0.4", |
@@ -32,7 +32,2 @@ ### Issues with HTTPS (including Heroku) has been resolved, module is working again | ||
path: '/status', | ||
auth: { | ||
// No authentication at all | ||
username: '', | ||
password: ''. | ||
}, | ||
spans: [{ | ||
@@ -53,2 +48,2 @@ interval: 1, // Every second | ||
[MIT License](https://opensource.org/licenses/MIT) © Rafal Wilinski | ||
[MIT License](https://opensource.org/licenses/MIT) © Rafal Wilinski |
Sorry, the diff of this file is not supported yet
3
10
354
17308
48
- Removedbasic-auth@^1.0.4
- Removedbasic-auth@1.1.0(transitive)