bitcore-node-zcash/app/controllers/status.js

51 lines
915 B
JavaScript
Raw Normal View History

'use strict';
/**
* Module dependencies.
*/
var Status = require('../models/Status');
/**
* Status
*/
2014-01-16 08:32:11 -08:00
exports.show = function(req, res, next) {
if (! req.query.q) {
res.status(400).send('Bad Request');
}
else {
var s = req.query.q;
var d = Status.new();
2014-01-16 08:32:11 -08:00
if (s === 'getInfo') {
d.getInfo(function(err) {
if (err) next(err);
res.jsonp(d);
});
}
2014-01-16 08:32:11 -08:00
else if (s === 'getDifficulty') {
d.getDifficulty(function(err) {
if (err) next(err);
res.jsonp(d);
});
}
2014-01-16 08:32:11 -08:00
else if (s === 'getTxOutSetInfo') {
d.getTxOutSetInfo(function(err) {
if (err) next(err);
res.jsonp(d);
});
}
2014-01-16 08:32:11 -08:00
else if (s === 'getBestBlockHash') {
d.getBestBlockHash(function(err) {
if (err) next(err);
res.jsonp(d);
});
}
else {
res.status(400).send('Bad Request');
}
}
};