2018-02-03 21:14:56 +05:00
|
|
|
var models = require('../models');
|
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
|
|
|
|
/* GET home page. */
|
2018-02-03 23:54:25 +05:00
|
|
|
router.get('/:hash', async function(req, res, next) {
|
2018-02-03 21:14:56 +05:00
|
|
|
const hash = encodeURI(req.params.hash);
|
2018-02-03 23:54:25 +05:00
|
|
|
const block = await models.Block.findOne({
|
2018-02-03 21:14:56 +05:00
|
|
|
where: {
|
|
|
|
hash,
|
|
|
|
},
|
|
|
|
include: {
|
|
|
|
model: models.Transaction,
|
|
|
|
},
|
|
|
|
})
|
2018-02-03 23:54:25 +05:00
|
|
|
if (block === null) {
|
|
|
|
res.status(404).render('404');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
block.dataValues.time = block.time.toUTCString();
|
|
|
|
res.render('block', {
|
|
|
|
block,
|
2018-02-03 21:14:56 +05:00
|
|
|
});
|
2018-02-03 23:54:25 +05:00
|
|
|
|
2018-02-03 21:14:56 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|