Merge pull request #14 from KevinMidboe/client_feature

Client feature
This commit is contained in:
2017-07-16 11:19:15 +02:00
committed by GitHub
9 changed files with 187 additions and 45 deletions

View File

@@ -0,0 +1,24 @@
const RequestRepository = require('src/plex/requestRepository.js');
const requestRepository = new RequestRepository();
/**
* Controller: POST a media id to be donwloaded
* @param {Request} req http request variable
* @param {Response} res
* @returns {Callback}
*/
function submitRequestController(req, res) {
// This is the id that is the param of the url
const id = req.params.mediaId;
requestRepository.sendRequest(id)
.then(() => {
res.send({ success: true, message: 'Media item sucessfully requested!' });
})
.catch((error) => {
res.status(500).send({ success: false, error: error.message });
});
}
module.exports = submitRequestController;