import * as express from "express";
const router = express.Router();

router.use((req, res, next) => {
  if (!req.cookies || !req.cookies.uid) {
    res.status(404);
    res.send();
  } else {
    next();
  }
});

router.get("/", (req, res, next) => {
  const user = req.app.db.get("users").find({id: req.cookies.uid}).value();
  console.log(user);
  res.render("index", {title: "Liebingscocktails", user, cocktails: req.app.cocktails, cocktailList: req.app.cocktailList});
});

export = router;
