const express = require("express");
const pool = require("./db");
const scheduleChecks = require("./scheduler");

const app = express();
app.set("view engine", "ejs");
app.use(express.static("public"));

app.get("/", async (req, res) => {
  const { rows } = await pool.query("SELECT * FROM checks ORDER BY id");
  res.render("index", { checks: rows });
});

app.listen(3000, async () => {
  console.log("Server läuft auf Port 3000");
  await scheduleChecks();
});
