Blockchain explorer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

7 years ago
var models = require('../models');
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/:address/:offset*?', async function(req, res, next) {
7 years ago
const safe_address = encodeURI(req.params.address);
7 years ago
const limit = 3;
const paramPage = parseInt(req.params.offset);
const page = isNaN(paramPage) || paramPage < 1 ? 1 : paramPage;
const offset = limit * (page - 1);
// const transactions = await models.Transaction.findAll({
// include: {
// model: models.Vout,
// include: {
// model: models.Address,
// where: {
// address: safe_address,
// },
// },
// },
// raw: true,
// offset: offset,
// limit: limit,
// });
const vouts = await models.Vout.findAll({
7 years ago
raw: true,
7 years ago
include: [{
// attributes: [],
model: models.Address,
where: {
address: safe_address,
}
}, {
attributes: ['txid'],
model: models.Transaction,
}],
// offset,
// limit,
});
7 years ago
console.log(vouts);
7 years ago
7 years ago
if (vouts === null) {
res.status(404).render('404');
return;
}
7 years ago
// console.log(transactions);
const nextpage = vouts.length === 30 ? page + 1 : null;
const prevpage = page > 1 ? page - 1 : null;
res.render('address', {
7 years ago
address: safe_address,
7 years ago
vouts,
nextpage,
prevpage,
7 years ago
});
});
module.exports = router;