An even more educational version of the Bandolier for Learn JS the Hard Way.
https://learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
409 B
17 lines
409 B
import { ToDo } from "../lib/models.js";
|
|
import nunjucks from "nunjucks";
|
|
|
|
export const get = async (req, rep) => {
|
|
const todo_list = await ToDo.all({});
|
|
rep.code(200).send(todo_list);
|
|
}
|
|
|
|
export const post = async (req, rep) => {
|
|
if(req.query.todo_id !== undefined) {
|
|
await ToDo.delete({id: req.query.todo_id});
|
|
} else {
|
|
await ToDo.insert({task: req.body.task});
|
|
}
|
|
|
|
await get(req, rep);
|
|
}
|
|
|