TX API working + sync
This commit is contained in:
parent
dac973c65f
commit
7002363841
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var Transaction = require('../models/Transaction');
|
||||
//, _ = require('lodash');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Find block by hash ...
|
||||
*/
|
||||
exports.transaction = function(req, res, next, txid) {
|
||||
Transaction.fromID(txid, function(err, tx) {
|
||||
if (err) return next(err);
|
||||
if (!tx) return next(new Error('Failed to load TX ' + txid));
|
||||
req.transaction = tx;
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Show block
|
||||
*/
|
||||
exports.show = function(req, res) {
|
||||
res.jsonp(req.transaction);
|
||||
};
|
||||
|
|
@ -7,11 +7,13 @@ module.exports = function(app) {
|
|||
app.get('/', index.render);
|
||||
|
||||
//Block routes
|
||||
|
||||
var blocks = require('../app/controllers/blocks');
|
||||
app.get('/block/:blockHash', blocks.show);
|
||||
|
||||
|
||||
app.param('blockHash', blocks.block);
|
||||
|
||||
var transactions = require('../app/controllers/transactions');
|
||||
app.get('/tx/:txid', transactions.show);
|
||||
|
||||
app.param('txid', transactions.transaction);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue