diff --git a/seasoned_api/src/webserver/controllers/plex/fetchRequested.js b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js new file mode 100644 index 0000000..18b92fc --- /dev/null +++ b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js @@ -0,0 +1,23 @@ +const RequestRepository = require('src/plex/requestRepository.js'); +const requestRepository = new RequestRepository(); + +/** + * Controller: Retrieves search history of a logged in user + * @param {Request} req http request variable + * @param {Response} res + * @returns {Callback} + */ +function historyController(req, res) { + const user = req.loggedInUser; + console.log('here') + + requestRepository.fetchRequested() + .then((requestedItems) => { + res.send({ success: true, requestedItems }); + }) + .catch((error) => { + res.status(401).send({ success: false, error: error.message }); + }); +} + +module.exports = historyController;