const express = require('express'),
    router = express.Router(),
    Document = require("../src/sequelize.js").Document;
    templateArgs = require('../src/templateArgs.js');

/* GET home page. */
router.get('/', function(req, res, next) {
  templateArgs.generate(req).then(async args => {
    if (args.user) {
      args.books = await Document.getLastInserted(10);
      res.render("indexUser", args);
    } else {
      res.render("index", args);
    }
  });
});

module.exports = router;
