TX API working + sync

This commit is contained in:
Matias Alejo Garcia 2014-01-08 01:47:20 -03:00
parent dac973c65f
commit 7002363841
2 changed files with 38 additions and 3 deletions

View File

@ -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);
};

View File

@ -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);
};