Browse Source

Seperate Onionoo API client out into seperate package

pm2
Luke Childs 8 years ago
parent
commit
0c33b91a9d
  1. 20
      lib/onionoo.js
  2. 3
      package.json
  3. 2
      viewModels/listing.js

20
lib/onionoo.js

@ -1,20 +0,0 @@
const rp = require('request-promise');
const baseUrl = 'https://onionoo.torproject.org/';
const endpoints = [
'summary',
'details',
'bandwidth',
'weights',
'clients',
'uptime'
];
module.exports = endpoints.reduce((onionoo, endpoint) => {
onionoo[endpoint] = args => rp({
uri: `${baseUrl}${endpoint}`,
qs: args,
json: true
});
return onionoo;
}, {});

3
package.json

@ -6,8 +6,7 @@
"dependencies": {
"express": "^4.14.0",
"nunjucks": "^2.4.2",
"request": "^2.74.0",
"request-promise": "^4.1.1"
"onionoo": "^0.1.0"
},
"devDependencies": {},
"scripts": {

2
viewModels/listing.js

@ -1,4 +1,4 @@
onionoo = require('../lib/onionoo');
onionoo = require('onionoo');
module.exports = (req, res) => {
onionoo

Loading…
Cancel
Save