Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cluster2

Package Overview
Dependencies
Maintainers
5
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster2 - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

168

lib/monitor.js

@@ -31,97 +31,101 @@ /*

var app = options.monitor || express.createServer();
var app = options.monitor;
var self = this;
app.set('views', __dirname + '/../public/views');
app.use(express.static(__dirname + '/../public'));
app.set('view engine', 'html');
if(!app){
app = express.createServer();
app.get(this.options.path, function (req, res) {
var accept = (req.headers || {}).accept || '';
if(accept.search('json') > 0) {
res.contentType('application/json');
res.send(JSON.stringify(getStats(self.stats, req.connection)));
}
else {
res.render('index.ejs', getStats(self.stats, req.connection));
}
});
var self = this;
app.set('views', __dirname + '/../public/views');
app.use(express.static(__dirname + '/../public'));
app.set('view engine', 'html');
app.get(/^\/logs?(?:\/(\d+)(?:\.\.(\d+))?)?/, function (req, res) {
var root, paths, logs, stats;
var file = process.cwd() + req.url;
if(req.url === '/logs') {
root = process.cwd() + '/logs';
paths = fs.readdirSync(root);
logs = [];
paths.forEach(function (filename) {
stats = fs.statSync(root + '/' + filename);
logs.push({
filename: filename,
stats: stats
})
});
var data = getStats(self.stats, req.connection);
data.logs = logs;
res.render('logs.ejs', data);
}
else {
var stat = fs.statSync(file);
res.writeHead(200, {
'Content-Type': 'text/plain',
'Content-Length': stat.size
});
var readStream = fs.createReadStream(file);
util.pump(readStream, res, function (e) {
if(e) {
console.error(e.stack || e);
}
res.end();
});
}
});
app.get(this.options.path, function (req, res) {
var accept = (req.headers || {}).accept || '';
if(accept.search('json') > 0) {
res.contentType('application/json');
res.send(JSON.stringify(getStats(self.stats, req.connection)));
}
else {
res.render('index.ejs', getStats(self.stats, req.connection));
}
});
app.get('/deps', function(req, res) {
npm.load({}, function() {
npm.commands.ls([], true, function(e, data) {
app.get(/^\/logs?(?:\/(\d+)(?:\.\.(\d+))?)?/, function (req, res) {
var root, paths, logs, stats;
var file = process.cwd() + req.url;
if(req.url === '/logs') {
root = process.cwd() + '/logs';
paths = fs.readdirSync(root);
logs = [];
paths.forEach(function (filename) {
stats = fs.statSync(root + '/' + filename);
logs.push({
filename: filename,
stats: stats
})
});
var data = getStats(self.stats, req.connection);
data.logs = logs;
res.render('logs.ejs', data);
}
else {
var stat = fs.statSync(file);
res.writeHead(200, {
'Content-Type': 'application/json'
'Content-Type': 'text/plain',
'Content-Length': stat.size
});
var readStream = fs.createReadStream(file);
util.pump(readStream, res, function (e) {
if(e) {
console.error(e.stack || e);
}
res.end();
});
}
});
var seen = [];
var out = JSON.stringify(data, function (k, o) {
if(typeof o === "object") {
if(-1 !== seen.indexOf(o)) return '[Circular]';
seen.push(o);
}
return o;
}, 2);
res.end(out);
app.get('/deps', function(req, res) {
npm.load({}, function() {
npm.commands.ls([], true, function(e, data) {
res.writeHead(200, {
'Content-Type': 'application/json'
});
var seen = [];
var out = JSON.stringify(data, function (k, o) {
if(typeof o === "object") {
if(-1 !== seen.indexOf(o)) return '[Circular]';
seen.push(o);
}
return o;
}, 2);
res.end(out);
});
});
});
});
app.get('/ComponentStatus(/[^/]+)?', function(req, res){
app.get('/ComponentStatus(/[^/]+)?', function(req, res){
//when component = empty, this will list all the component ids and links associated with them.
//when component = empty, this will list all the component ids and links associated with them.
//otherwise, we'll collect the component status from all workers
var component = req.query.component, //should come from param
view = req.query.view || 'html',//should come from param
worker = req.query.worker,
componentStatus = require("./component-status.js").componentStatus;
//otherwise, we'll collect the component status from all workers
var component = req.query.component, //should come from param
view = req.query.view || 'html',//should come from param
worker = req.query.worker,
componentStatus = require("./component-status.js").componentStatus;
if(component){
componentStatus.getStatus(component, {
'params': req.query,
'worker': worker,
'done': function(result){
res.send(JSON.stringify(result), 200);
}
});
}
else{
res.send(JSON.stringify(componentStatus.getComponents()), 200);
}
});
if(component){
componentStatus.getStatus(component, {
'params': req.query,
'worker': worker,
'done': function(result){
res.send(JSON.stringify(result), 200);
}
});
}
else{
res.send(JSON.stringify(componentStatus.getComponents()), 200);
}
});
}

@@ -128,0 +132,0 @@ return app;

@@ -8,3 +8,3 @@ {

"name": "cluster2",
"version": "0.4.1",
"version": "0.4.2",
"repository": {

@@ -11,0 +11,0 @@ "type": "git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc