Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
SOD/routes/index.js

30 lines
747 B
JavaScript
Raw Normal View History

2020-06-26 16:59:54 +02:00
let express = require("express");
let router = express.Router();
let models = require("../models");
2020-06-26 16:59:54 +02:00
router.get("/", async (req, res) => {
2020-08-24 23:23:46 +02:00
let now = new Date();
let firstDate = await models.Data.findByPk("firstDate");
if (firstDate && firstDate.value) {
firstDate = new Date(firstDate.value);
if (firstDate.getTime() < now.getTime())
firstDate = now;
} else
firstDate = now;
firstDate = firstDate.toISOString().substring(0, 10);
res.render("index", {
title: "SOD - Home",
departments: await models.Department.findAll(),
sandwiches: await models.Sandwich.findAll(),
date: {
firstDate: firstDate,
lastDate: await models.Data.findByPk("lastDate")
}
});
2020-06-26 16:59:54 +02:00
});
module.exports = router;