For blocks info, we always use controller blocks. Index controller only render homepage
This commit is contained in:
parent
76862dc0f9
commit
c2bbdb2941
@ -29,3 +29,18 @@ exports.show = function(req, res) {
|
|||||||
res.jsonp(req.block);
|
res.jsonp(req.block);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of blocks at HomePage
|
||||||
|
*/
|
||||||
|
exports.last_blocks = function(req, res) {
|
||||||
|
Block.find().limit(7).exec(function(err, blocks) {
|
||||||
|
if (err) {
|
||||||
|
res.render('error', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.jsonp(blocks);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var mongoose = require('mongoose'),
|
|
||||||
Block = mongoose.model('Block');
|
|
||||||
|
|
||||||
exports.render = function(req, res) {
|
exports.render = function(req, res) {
|
||||||
res.render('index');
|
res.render('index');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* List of blocks at HomePage
|
|
||||||
*/
|
|
||||||
exports.all = function(req, res) {
|
|
||||||
Block.find().limit(7).exec(function(err, blocks) {
|
|
||||||
if (err) {
|
|
||||||
res.render('error', {
|
|
||||||
status: 500
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.jsonp(blocks);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|||||||
@ -5,12 +5,12 @@ module.exports = function(app) {
|
|||||||
//Home route
|
//Home route
|
||||||
var index = require('../app/controllers/index');
|
var index = require('../app/controllers/index');
|
||||||
app.get('/', index.render);
|
app.get('/', index.render);
|
||||||
app.get('/last_blocks', index.all);
|
|
||||||
|
|
||||||
//Block routes
|
//Block routes
|
||||||
var blocks = require('../app/controllers/blocks');
|
var blocks = require('../app/controllers/blocks');
|
||||||
app.get('/block/:blockHash', blocks.show);
|
app.get('/block/:blockHash', blocks.show);
|
||||||
app.param('blockHash', blocks.block);
|
app.param('blockHash', blocks.block);
|
||||||
|
app.get('/last_blocks', blocks.last_blocks);
|
||||||
|
|
||||||
var transactions = require('../app/controllers/transactions');
|
var transactions = require('../app/controllers/transactions');
|
||||||
app.get('/tx/:txid', transactions.show);
|
app.get('/tx/:txid', transactions.show);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user