Skip to content

Instantly share code, notes, and snippets.

@wmantly
Created January 29, 2014 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmantly/8698481 to your computer and use it in GitHub Desktop.
Save wmantly/8698481 to your computer and use it in GitHub Desktop.
var passwordHash = require('password-hash'),
redis = require("redis"),
client = redis.createClient(),
extend = require('node.extend');
exports.list = function(req, res){
/*if(!req.session.auth){
res.redirect('login?redirect=hosts');
}*/
if(req.xhr){
var jsonObj = {};
client.SMEMBERS("hosts", function (err, replies) {
replies.forEach(function(host){
client.HGETALL(host, function(err, repliesHost){
jsonObj[host] = extend({host: host}, repliesHost);
console.log(jsonObj[host]);
});
});
/*console.log(jsonObj);*/
res.json(jsonObj);
});
} else {
res.render('hosts', {});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment