Get a request item by id and type

This commit is contained in:
2019-06-28 19:21:54 +02:00
parent ac027a97d6
commit 9f1badc1b1
3 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
const RequestRepository = require('src/request/request');
const request = new RequestRepository();
/**
* Controller: Get requested item by tmdb id and type
* @param {Request} req http request variable
* @param {Response} res
* @returns {Callback}
*/
function fetchAllRequests(req, res) {
const id = req.params.id;
const { type } = req.query;
Promise.resolve()
.then(() => request.getRequestByIdAndType(id, type))
.then((result) => res.send(result))
.catch((error) => {
res.status(404).send({ success: false, error: error.message });
});
}
module.exports = fetchAllRequests;