import { ToDo } from "../lib/models.js"; import nunjucks from "nunjucks"; export const get = async (req, rep) => { const todo_list = await ToDo.all({}); const result = nunjucks.render("todo.html", {todo_list, name: "Zed"}); rep.code(200).type("text/html").send(result); } export const post = async (req, rep) => { if(req.query.todo_id !== undefined) { await ToDo.delete({id: req.query.todo_id}); } else { console.log("ADDING TASK", req.body.task); await ToDo.insert({task: req.body.task}); } // this is how you can prevent the annoying double submit rep.redirect("/todo"); }