diff --git a/app/controllers/misc.js b/app/controllers/misc.js index 57c5fd78b..0accaa0e6 100644 --- a/app/controllers/misc.js +++ b/app/controllers/misc.js @@ -18,3 +18,26 @@ exports.getServiceAddresses = function(req, res, next) { } }); }; + + +exports.getNpoList = function(req, res, next) { + if( req.params.npolistid || !(req.params.npolistid === "") ){ + bdb.getNpoList(req.params.npolistid, function(err, result){ + if(err){ + console.log("printing out error"); + console.log(err); + return common.handleErrors(err, res); + } + else { + console.log("printing out result"); + console.log(result); + res.jsonp(result.result); + } + }); + } else { + res.send("No address provided"); + } + +} + + diff --git a/config/routes.js b/config/routes.js index c1aff93b3..c12ca9a24 100644 --- a/config/routes.js +++ b/config/routes.js @@ -13,8 +13,6 @@ module.exports = function(app) { var blocks = require('../app/controllers/blocks'); app.get(apiPrefix + '/blocks', blocks.list); - - app.get(apiPrefix + '/block/:blockHash', blocks.show); app.param('blockHash', blocks.block); @@ -24,6 +22,7 @@ module.exports = function(app) { // Service Addresses var misc = require('../app/controllers/misc'); app.get(apiPrefix + '/getserviceaddresses', misc.getServiceAddresses); + app.get(apiPrefix + '/getnpolist/:npolistid', misc.getNpoList); // Transaction routes var transactions = require('../app/controllers/transactions'); @@ -94,4 +93,4 @@ module.exports = function(app) { var index = require('../app/controllers/index'); app.get(apiPrefix + '/version', index.version); app.get('*', index.render); -}; \ No newline at end of file +}; diff --git a/lib/BlockDb.js b/lib/BlockDb.js index 4903ee604..e45861c8f 100644 --- a/lib/BlockDb.js +++ b/lib/BlockDb.js @@ -479,4 +479,8 @@ BlockDb.prototype.getServiceAddresses = function(cb) { return Rpc.getServiceAddresses(cb); }; -module.exports = require('soop')(BlockDb); \ No newline at end of file +BlockDb.prototype.getNpoList = function(npolistid, cb) { + return Rpc.getNpoList(npolistid, cb); +} + +module.exports = require('soop')(BlockDb); diff --git a/lib/Rpc.js b/lib/Rpc.js index e7c887a05..57a2fe922 100644 --- a/lib/Rpc.js +++ b/lib/Rpc.js @@ -119,4 +119,13 @@ Rpc.getServiceAddresses = function(cb) { return cb(err, sa); }); }; -module.exports = require('soop')(Rpc); \ No newline at end of file + +Rpc.getNpoList = function(npolistId, cb){ + bitcoreRpc.getNpoList(npolistId, + function(err, npolist) { + if(err) return cb(err); + return cb(err, npolist); + }); +} + +module.exports = require('soop')(Rpc);