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.

46 lines
899 B

6 years ago
var models = require('../models');
var express = require('express');
var router = express.Router();
/* GET home page. */
router.post('/', async function(req, res, next) {
6 years ago
const search = encodeURI(req.body.search);
// looking for address
const address = await models.Address.findOne({
6 years ago
where: {
address: search,
},
});
if (address) {
res.redirect(`/address/${address.address}`);
return;
}
// looking for transaction
const transaction = await models.Transaction.findOne({
where: {
txid: search,
},
});
if (transaction) {
res.redirect(`/transaction/${transaction.txid}`);
return;
}
// looking for block
const block = await models.Block.findOne({
where: {
hash: search,
},
});
if (block) {
res.redirect(`/block/${block.hash}`);
return;
}
res.status(404).render('404');
6 years ago
});
module.exports = router;