Skip to content

Commit

Permalink
Get tasks by user
Browse files Browse the repository at this point in the history
  • Loading branch information
anagmrebelo committed Aug 14, 2023
1 parent 2e26d07 commit 5d822c5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ app.post<{}, {}, DbTask>("/tasks", async (req, res) => {
res.status(201).json(createdTask);
});

// GET /tasks/:id
app.get<{ id: string }>("/tasks/:id", async (req, res) => {
const matchingTask = await getDbTaskById(parseInt(req.params.id));
if (matchingTask === "not found") {
res.status(404).json(matchingTask);
} else {
res.status(200).json(matchingTask);
}
// GET /tasks/:user
app.get<{ userId: string }>("/tasks/:userId", async (req, res) => {
const allTasks = await getAllDbTasks(parseInt(req.params.userId));
res.status(200).json(allTasks);
});

// DELETE /tasks/:id
Expand Down

0 comments on commit 5d822c5

Please sign in to comment.