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 as any).db.get("users").find({id: req.cookies.uid}).value();
  res.render("index", {title: "Liebingscocktails", user, cocktails: (req.app as any).cocktails, cocktailList: (req.app as any).cocktailList});
});

export = router;
