added trending images to homepage
This commit is contained in:
parent
476f28441c
commit
d3509c5d98
2 changed files with 14 additions and 4 deletions
|
@ -1,15 +1,23 @@
|
|||
const logger = require('winston');
|
||||
const { postToStats } = require('../controllers/statsController.js');
|
||||
const { postToStats, getTrendingClaims } = require('../controllers/statsController.js');
|
||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||
|
||||
module.exports = app => {
|
||||
// route for the home page
|
||||
app.get('/', ({ headers, ip, originalUrl }, res) => {
|
||||
// get yesterday's date
|
||||
const startDate = new Date();
|
||||
startDate.setDate(startDate.getDate() - 1);
|
||||
// send response
|
||||
res.status(200).render('index');
|
||||
getTrendingClaims(startDate)
|
||||
.then(result => {
|
||||
res.status(200).render('index', { trendingAssets: result });
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError(error, res);
|
||||
});
|
||||
});
|
||||
// a catch-all route if someone visits a page that does not exist
|
||||
app.use('*', ({ originalUrl, ip }, res) => {
|
||||
logger.error(`404 on ${originalUrl}`);
|
||||
// post to stats
|
||||
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
|
||||
// send response
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<div class="full">
|
||||
{{> publish}}
|
||||
{{> learnMore}}
|
||||
{{> trendingAssets}}
|
||||
</div>
|
||||
{{> footer}}
|
||||
</div>
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
|
|
Loading…
Reference in a new issue