You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
662 B
30 lines
662 B
8 years ago
|
const tor = require('../lib/tor');
|
||
8 years ago
|
|
||
8 years ago
|
module.exports = (req, res) => {
|
||
8 years ago
|
|
||
8 years ago
|
let title = 'Top 10 nodes by consensus weight';
|
||
8 years ago
|
const query = {
|
||
|
limit: 10
|
||
|
};
|
||
|
if(req.query.s) {
|
||
8 years ago
|
title = `Search results for "${req.query.s}":`;
|
||
8 years ago
|
query.search = req.query.s;
|
||
8 years ago
|
if(req.query.p) {
|
||
|
query.offset = (query.limit * req.query.p) - query.limit;
|
||
|
}
|
||
8 years ago
|
} else {
|
||
|
query.order = '-consensus_weight';
|
||
|
query.running = true;
|
||
|
}
|
||
|
|
||
8 years ago
|
tor.listNodes(query)
|
||
|
.then(nodes => res.render('listing.html', {
|
||
|
title: title,
|
||
8 years ago
|
nodes: nodes,
|
||
|
numOfNodes: query.limit
|
||
8 years ago
|
}))
|
||
|
.catch(error => res.render('listing.html', {
|
||
|
error: error
|
||
|
}));
|
||
8 years ago
|
}
|