Renamed search_history controller to searchHistory
This commit is contained in:
24
seasoned_api/src/webserver/controllers/user/searchHistory.js
Normal file
24
seasoned_api/src/webserver/controllers/user/searchHistory.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const SearchHistory = require('src/searchHistory/searchHistory');
|
||||
|
||||
const searchHistory = new SearchHistory();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
const username = user === undefined ? undefined : user.username;
|
||||
|
||||
searchHistory.read(username)
|
||||
.then(searchQueries => {
|
||||
res.send({ success: true, searchQueries });
|
||||
})
|
||||
.catch(error => {
|
||||
res.status(404).send({ success: false, message: error.message });
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = historyController;
|
||||
Reference in New Issue
Block a user