Moved eveything related to the api to a seperate folder seasoned_api.

This commit is contained in:
2017-08-06 16:45:02 +02:00
parent f53ab55d96
commit 47aa638fd8
44 changed files with 7 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
const RequestRepository = require('src/plex/requestRepository.js');
const requestRepository = new RequestRepository();
function searchRequestController(req, res) {
const { query, page, type } = req.query;
console.log('searchReq: ' + query, page, type);
requestRepository.searchRequest(query, page, type)
.then((movies) => {
// Verify that respond has content, if so send the content back
if (movies.length > 0 && movies != null) {
res.send(movies);
}
// If no content was found, send 404 status and error message
else {
res.status(404).send({success: false, error: 'Search query did not return any results.'})
}
})
.catch((error) => {
res.status(500).send({success: false, error: error.message });
})
}
module.exports = searchRequestController;