
const User = require("./sequelize.js").User();

module.exports.generate = function(req) {
  var args = {
    title: "Totoro Book",
  };
  return new Promise((res, rej) => {
    if (req && req.session && req.session.userId) {
        User.findAll({ where: { id: req.session.userId }}).then(users => {
          if (users && users[0]) {
            args.user = users[0];
            args.username = args.user.username;
          }
          res(args);
        });
    } else {
      res(args);
    }
  });
}

