-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement endpoint to retrieve a sorted list of unique authors. Added…
… support for filtering by quoteCategory. (#131)
- Loading branch information
1 parent
472893b
commit 6b736e6
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const quoteService = require("../services/quotesService"); | ||
|
||
const authorsController = async (req, res, next) => { | ||
|
||
try { | ||
|
||
let quotesUrl = req.query.quotesUrl || ''; | ||
|
||
let quoteCategory = req.query.quoteCategory || ''; | ||
|
||
let quoteObject = { | ||
quotesUrl, | ||
quoteCategory, | ||
} | ||
|
||
const authors = await quoteService.getAuthors(quoteObject); | ||
|
||
res.setHeader("Content-Type", "application/json"); | ||
|
||
res.header( | ||
"Cache-Control", | ||
"no-cache,max-age=0,no-store,s-maxage=0,proxy-revalidate" | ||
); | ||
res.header("Pragma", "no-cache"); | ||
res.header("Expires", "-1"); | ||
res.json(authors); | ||
|
||
} catch (error) { | ||
console.error(error); | ||
res.send({ | ||
name: error.name, | ||
message: error.message, | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
authorsController | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters