Skip to content

Commit

Permalink
feat: add route to list all files of a user
Browse files Browse the repository at this point in the history
  • Loading branch information
shabane committed Sep 27, 2024
1 parent 19bb4da commit cb088a1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,30 @@ router.post("/", file_upload_handler.array("files" ), (req, res, next) => {
});
});


router.get("/", (req, res) => {
find_user(req.cookies.username, req.cookies.password).then(user => {
if (!user) {
res.status(403).send(response_text["403"]);
return;
}

User_File.findAll({
where: {
user: user.id,
}
}).then(user_file => {
res.send(user_file);
}).catch(err => {
debug(err);
res.status(500).send(response_text["500"]);
return;
});
}).catch(err => {
debug(err);
res.status(500).send(response_text["500"]);
return;
});
});

exports.router = router;

0 comments on commit cb088a1

Please sign in to comment.