From dc358e21dc0e7ff2007f08e928c3abec050e5b9d Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Wed, 15 Feb 2023 12:57:00 +0100 Subject: [PATCH] added dummy share api --- router/album.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/router/album.js b/router/album.js index bf48490..a38a496 100644 --- a/router/album.js +++ b/router/album.js @@ -42,6 +42,15 @@ router.route("/newest/:count") }); }); +router.route("/filter/:term") + .get(passport.authenticate("jwt", { session: false }), (req, res) => { + process.stdout.write("router/album GET filter by term " + req.params.term + "\n"); + database.albums.filter(req.params.term, result => { + process.stdout.write("router/album GET filter by term " + req.params.term + " DB result\n"); + res.json(result); + }); + }) + router.route("/:id") .get(checkGuest, (req, res) => { process.stdout.write("router/album GET album by id " + req.params.id + "\n"); @@ -61,15 +70,6 @@ router.route("/:id") res.end(); }); -router.route("/filter/:term") - .get(passport.authenticate("jwt", { session: false }), (req, res) => { - process.stdout.write("router/album GET filter by term " + req.params.term + "\n"); - database.albums.filter(req.params.term, result => { - process.stdout.write("router/album GET filter by term " + req.params.term + " DB result\n"); - res.json(result); - }); - }) - router.route("/:id/cover") .put(passport.authenticate("jwt", { session: false }), (req, res) => { if (req.files) { @@ -116,4 +116,20 @@ router.route("/:id/move") }); }); +router.route("/:id/share") + .post(passport.authenticate("jwt", { session: false }), (req, res) => { + database.albums.byId(req.body.source, undefined, (result) => { + if (result != undefined && req.user.roles.indexOf("admin") > -1) { + process.write("Add shared abum"); + } + }); + }) + .delete(passport.authenticate("jwt", { session: false }), (req, res) => { + database.albums.byId(req.body.source, undefined, (result) => { + if (result != undefined && req.user.roles.indexOf("admin") > -1) { + process.write("Delete shared abum"); + } + }); + }); + module.exports = router; \ No newline at end of file