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