30 lines
662 B
30 lines
662 B
9 years ago
|
const tor = require('../lib/tor');
|
||
9 years ago
|
|
||
9 years ago
|
module.exports = (req, res) => {
|
||
9 years ago
|
|
||
9 years ago
|
let title = 'Top 10 nodes by consensus weight';
|
||
9 years ago
|
const query = {
|
||
|
limit: 10
|
||
|
};
|
||
|
if(req.query.s) {
|
||
9 years ago
|
title = `Search results for "${req.query.s}":`;
|
||
9 years ago
|
query.search = req.query.s;
|
||
9 years ago
|
if(req.query.p) {
|
||
|
query.offset = (query.limit * req.query.p) - query.limit;
|
||
|
}
|
||
9 years ago
|
} else {
|
||
|
query.order = '-consensus_weight';
|
||
|
query.running = true;
|
||
|
}
|
||
|
|
||
9 years ago
|
tor.listNodes(query)
|
||
|
.then(nodes => res.render('listing.html', {
|
||
|
title: title,
|
||
9 years ago
|
nodes: nodes,
|
||
|
numOfNodes: query.limit
|
||
9 years ago
|
}))
|
||
|
.catch(error => res.render('listing.html', {
|
||
|
error: error
|
||
|
}));
|
||
9 years ago
|
}
|