From bad112803ae05c297308992a544a8ce38b62515e Mon Sep 17 00:00:00 2001 From: Tim Basten Date: Thu, 26 Mar 2026 17:44:48 +0800 Subject: [PATCH] end of class --- backend/index.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/backend/index.js b/backend/index.js index 616471f..6de7e19 100644 --- a/backend/index.js +++ b/backend/index.js @@ -12,6 +12,51 @@ app.get("/test", async (req, res) => { res.send("Hello World!"); }); +const tasks = [ + { + id: 1, + completed: false, + title: "Buy groceries for the week", + description: "Pick up vegetables, fruits, milk, eggs, and bread from the supermarket.", + dueDate: "14/03/2026", + dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") + }, + { + id: 2, + completed: false, + title: "Clean the apartment", + description: "Vacuum the floors, wipe kitchen surfaces, and take out the trash.", + dueDate: "16/03/2026", + dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") + }, + { + id: 3, + completed: false, + title: "Call the dentist for appointment", + description: "Book a routine checkup and confirm available time slots for next week.", + dueDate: "17/03/2026", + dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") + }, + { + id: 4, + completed: true, + title: "Do laundry and fold clothes", + description: "Wash dark and light loads separately, then fold and organize clean clothes.", + dueDate: "21/03/2026", + dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") + } +]; + +app.get("/api/tasks", async (req, res) => { + try { + res.json(tasks); + } + catch (error) { + console.error(`Error: ${error}`) + res.status(500).json({ message: "Error getting tasks" }) + } +}); + app.listen(port, () => { console.log(`To Do App listening on port ${port}`); -}); \ No newline at end of file +});